MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / save_or_update

Method save_or_update

database/mongodb_store_base.py:105–113  ·  view source on GitHub ↗

Save or update data (upsert)

(self, collection_suffix: str, query: Dict, data: Dict)

Source from the content-addressed store, hash-verified

103 return db[collection_name]
104
105 async def save_or_update(self, collection_suffix: str, query: Dict, data: Dict) -> bool:
106 """Save or update data (upsert)"""
107 try:
108 collection = await self.get_collection(collection_suffix)
109 await collection.update_one(query, {"$set": data}, upsert=True)
110 return True
111 except Exception as e:
112 utils.logger.error(f"[MongoDBStoreBase] Save failed ({self.collection_prefix}_{collection_suffix}): {e}")
113 return False
114
115 async def find_one(self, collection_suffix: str, query: Dict) -> Optional[Dict]:
116 """Query a single record"""

Callers 15

testMethod · 0.95
store_contentMethod · 0.80
store_commentMethod · 0.80
store_contentMethod · 0.80
store_commentMethod · 0.80
store_contentMethod · 0.80
store_commentMethod · 0.80
store_contentMethod · 0.80
store_commentMethod · 0.80
store_contentMethod · 0.80
store_commentMethod · 0.80
store_contentMethod · 0.80

Calls 1

get_collectionMethod · 0.95

Tested by 1

testMethod · 0.76