From 220432c401626a9be074e35ff9e1383b75e0b5e9 Mon Sep 17 00:00:00 2001 From: Itz-fork Date: Mon, 1 Jan 2024 16:07:22 +0530 Subject: [PATCH] database: fix add command and exclude _id fields --- megadl/helpers/database.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/megadl/helpers/database.py b/megadl/helpers/database.py index c60719cb..969e23ff 100644 --- a/megadl/helpers/database.py +++ b/megadl/helpers/database.py @@ -29,7 +29,9 @@ async def add(self, user_id: int): no_modify=True, upsert=True, ) - return await self.mongoc.find_async(self.coll_users, {"_id": user_id}, {"status": 1}) + return (await self.mongoc.find_async( + self.coll_users, {"_id": user_id}, {"_id": 0, "status": 1} + ))["status"] async def plus_fl_count( self, user_id: int, downloads: int | None = None, uploads: int | None = None @@ -63,10 +65,9 @@ async def is_there(self, user_id: int, use_acc: bool = False): } """ uid = {"_id": user_id} - docu = await self.mongoc.find_async(self.coll_users, uid) + docu = await self.mongoc.find_async(self.coll_users, uid, {"_id": 0}) if not docu: return None - docu.pop("_id") if use_acc: return docu if not "" in {docu["email"], docu["password"]} else None else: