mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-01 10:25:45 +08:00
Add get by id method on DB adapter
This commit is contained in:
@ -15,6 +15,9 @@ class UserDBInterface:
|
||||
async def list(self) -> List[UserDB]:
|
||||
raise NotImplementedError()
|
||||
|
||||
async def get(self, id: str) -> UserDB:
|
||||
raise NotImplementedError()
|
||||
|
||||
async def get_by_email(self, email: str) -> UserDB:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@ -34,6 +34,10 @@ class SQLAlchemyUserDB(UserDBInterface):
|
||||
query = users.select()
|
||||
return await self.database.fetch_all(query)
|
||||
|
||||
async def get(self, id: str) -> UserDB:
|
||||
query = users.select().where(User.id == id)
|
||||
return await self.database.fetch_one(query)
|
||||
|
||||
async def get_by_email(self, email: str) -> UserDB:
|
||||
query = users.select().where(User.email == email)
|
||||
return await self.database.fetch_one(query)
|
||||
|
||||
Reference in New Issue
Block a user