Skip to content

Commit

Permalink
database: fix add command and exclude _id fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Itz-fork committed Jan 1, 2024
1 parent 7ab0914 commit 220432c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions megadl/helpers/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 220432c

Please sign in to comment.