From 8f27fff64666519a6429db9520b41f956258a3f7 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 30 Dec 2023 12:07:47 +0100 Subject: [PATCH] use email as _id for CONTACT_LIST_TO_BOOK --- src/db/mongo_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/db/mongo_manager.py b/src/db/mongo_manager.py index c2e80e2..5dcc3da 100644 --- a/src/db/mongo_manager.py +++ b/src/db/mongo_manager.py @@ -77,7 +77,9 @@ class MongoDbManager: try: collection_to_use = self.db[CONTACT_LIST_TO_BOOK] for contact in contact_list: - collection_to_use.insert_one(contact.to_firestore_dict()) + # collection_to_use.insert_one(contact.to_firestore_dict()) + collection_to_use.replace_one(filter={'_id': contact.mail, }, replacement=contact.to_firestore_dict(), + upsert=True) except Exception as Error: self.logger.info(Error)