Skip to content

Commit

Permalink
Add fetch_user_id query
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Dec 16, 2023
1 parent 8ab321c commit 9944b4a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions database/repositories/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def fetch_username(user_id: int) -> Optional[str]:
.filter(DBUser.id == user_id) \
.scalar()

def fetch_user_id(username: str) -> Optional[int]:
return app.session.database.session.query(DBUser.id) \
.filter(DBUser.name == username) \
.scalar()

def fetch_many(user_ids: tuple, *options) -> List[DBUser]:
return app.session.database.session.query(DBUser) \
.options(*[selectinload(item) for item in options]) \
Expand Down

0 comments on commit 9944b4a

Please sign in to comment.