From d014b0c79b5466eb16788a4e411952b32109a06d Mon Sep 17 00:00:00 2001 From: "codeshwar-preview[bot]" <160849357+codeshwar-preview[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:08:49 +0000 Subject: [PATCH] Updated the file in response to the PR comment --- API/database.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/API/database.py b/API/database.py index c15bd44..d1559dc 100644 --- a/API/database.py +++ b/API/database.py @@ -1,5 +1,6 @@ python from datetime import datetime + from pymongo import MongoClient @@ -9,7 +10,7 @@ def __init__(self, uri="mongodb://localhost:27017/", db_name="ImageDB"): self.db = self.client[db_name] def find(self, collection, query=None): - return list(self.db[collection].find(query)) + return self.db[collection].find(query) def insert_one(self, collection, document): return self.db[collection].insert_one(document) @@ -20,5 +21,5 @@ def find_one(self, collection, filter, projection=None): def find_one_and_delete(self, collection, query): return self.db[collection].find_one_and_delete(query) - def update_one(self, collection, filter, update): - return self.db[collection].update_one(filter, update) \ No newline at end of file + def update_one(self, collection, query, update, upsert=False): + return self.db[collection].update_one(filter=query, update=update, upsert=upsert) \ No newline at end of file