Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mhdrzn authored Aug 31, 2022
1 parent 28f90a8 commit d5d53a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions helper/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, uri, database_name):

def new_user(self, id):
return dict(
_id=id,
_id=int(id),
file_id=None,
caption=None
)
Expand All @@ -24,7 +24,7 @@ async def add_user(self, id):

async def is_user_exist(self, id):
user = await self.col.find_one({'_id': int(id)})
return True if user else False
return bool(user)

async def total_users_count(self):
count = await self.col.count_documents({})
Expand All @@ -38,14 +38,14 @@ async def delete_user(self, user_id):
await self.col.delete_many({'_id': int(user_id)})

async def set_thumbnail(self, id, file_id):
await self.col.update_one({'_id': id}, {'$set': {'file_id': file_id}})
await self.col.update_one({'_id': int(id)}, {'$set': {'file_id': file_id}})

async def get_thumbnail(self, id):
user = await self.col.find_one({'_id': int(id)})
return user.get('file_id', None)

async def set_caption(self, id, caption):
await self.col.update_one({'_id': id}, {'$set': {'caption': caption}})
await self.col.update_one({'_id': int(id)}, {'$set': {'caption': caption}})

async def get_caption(self, id):
user = await self.col.find_one({'_id': int(id)})
Expand Down

0 comments on commit d5d53a2

Please sign in to comment.