Update user repository implementation.
This commit is contained in:
Binary file not shown.
@@ -20,11 +20,13 @@ class UsersRepo:
|
|||||||
|
|
||||||
async def get_user(self, user_id: int):
|
async def get_user(self, user_id: int):
|
||||||
user = await self.collection.find_one({"user_id": user_id})
|
user = await self.collection.find_one({"user_id": user_id})
|
||||||
|
if user:
|
||||||
user["id"] = str(user["_id"])
|
user["id"] = str(user["_id"])
|
||||||
return user
|
return user
|
||||||
|
|
||||||
async def get_user_by_username(self, username: str):
|
async def get_user_by_username(self, username: str):
|
||||||
user = await self.collection.find_one({"username": username})
|
user = await self.collection.find_one({"username": username})
|
||||||
|
if user:
|
||||||
user["id"] = str(user["_id"])
|
user["id"] = str(user["_id"])
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ class UsersRepo:
|
|||||||
}
|
}
|
||||||
result = await self.collection.insert_one(user_doc)
|
result = await self.collection.insert_one(user_doc)
|
||||||
user = await self.collection.find_one({"_id": result.inserted_id})
|
user = await self.collection.find_one({"_id": result.inserted_id})
|
||||||
|
if user:
|
||||||
user["id"] = str(user["_id"])
|
user["id"] = str(user["_id"])
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user