MCPcopy Create free account
hub / github.com/Boris-code/feapder / update_many

Method update_many

feapder/db/mongodb.py:337–362  ·  view source on GitHub ↗

批量更新 Args: coll_name: 集合名 data: 单条数据 {"xxx":"xxx"} condition: 更新条件 {"_id": "xxxx"} upsert: 数据不存在则插入,默认为 False Returns: True / False

(self, coll_name, data: Dict, condition: Dict, upsert: bool = False)

Source from the content-addressed store, hash-verified

335 return True
336
337 def update_many(self, coll_name, data: Dict, condition: Dict, upsert: bool = False):
338 """
339 批量更新
340 Args:
341 coll_name: 集合名
342 data: 单条数据 {"xxx":"xxx"}
343 condition: 更新条件 {"_id": "xxxx"}
344 upsert: 数据不存在则插入,默认为 False
345
346 Returns: True / False
347 """
348 try:
349 collection = self.get_collection(coll_name)
350 collection.update_many(condition, {"$set": data}, upsert=upsert)
351 except Exception as e:
352 log.error(
353 """
354 error:{}
355 condition: {}
356 """.format(
357 e, condition
358 )
359 )
360 return False
361 else:
362 return True
363
364 def update_batch(
365 self,

Callers 1

mongodb.pyFile · 0.80

Calls 2

get_collectionMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected