From f6919ccd9324afe34835fa708c544cca0fcd5513 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 16 Apr 2024 09:42:33 -0500 Subject: [PATCH] bug fix: set function mongodb used for updates --- transport/nosql/mongodb.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/transport/nosql/mongodb.py b/transport/nosql/mongodb.py index c498704..7c5b8b2 100644 --- a/transport/nosql/mongodb.py +++ b/transport/nosql/mongodb.py @@ -12,7 +12,8 @@ from bson.binary import Binary from datetime import datetime import pandas as pd import numpy as np -import gridfs +# import gridfs +from gridfs import GridFS import sys import json import re @@ -243,13 +244,17 @@ class Writer(Mongo): """ collection = self.db[self.collection] - if collection.count_document() > 0 and '_id' in document: + if collection.count_documents() > 0 and '_id' in document: id = document['_id'] del document['_id'] collection.find_one_and_replace({'_id':id},document) else: - collection.delete_many({}) - self.write(info) + # + # Nothing to be done if we did not find anything + # + pass + # collection.delete_many({}) + # self.write(info) def close(self): Mongo.close(self) # collecton.update_one({"_id":self.collection},document,True)