Update user repository implementation.

This commit is contained in:
xds
2026-02-09 16:16:55 +03:00
parent 458b6ebfc3
commit a9d24c725e
2 changed files with 6 additions and 3 deletions

View File

@@ -20,11 +20,13 @@ class UsersRepo:
async def get_user(self, user_id: int):
user = await self.collection.find_one({"user_id": user_id})
if user:
user["id"] = str(user["_id"])
return user
async def get_user_by_username(self, username: str):
user = await self.collection.find_one({"username": username})
if user:
user["id"] = str(user["_id"])
return user
@@ -48,6 +50,7 @@ class UsersRepo:
}
result = await self.collection.insert_one(user_doc)
user = await self.collection.find_one({"_id": result.inserted_id})
if user:
user["id"] = str(user["_id"])
return user