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

Method update

feapder/db/mongodb.py:310–335  ·  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

308 return result["n"]
309
310 def update(self, coll_name, data: Dict, condition: Dict, upsert: bool = False):
311 """
312 更新
313 Args:
314 coll_name: 集合名
315 data: 单条数据 {"xxx":"xxx"}
316 condition: 更新条件 {"_id": "xxxx"}
317 upsert: 数据不存在则插入,默认为 False
318
319 Returns: True / False
320 """
321 try:
322 collection = self.get_collection(coll_name)
323 collection.update_one(condition, {"$set": data}, upsert=upsert)
324 except Exception as e:
325 log.error(
326 """
327 error:{}
328 condition: {}
329 """.format(
330 e, condition
331 )
332 )
333 return False
334 else:
335 return True
336
337 def update_many(self, coll_name, data: Dict, condition: Dict, upsert: bool = False):
338 """

Callers 1

findMethod · 0.45

Calls 2

get_collectionMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected