users: get user by id, email, username
This commit is contained in:
parent
b8f6cae85e
commit
d790d2ff29
8 changed files with 254 additions and 6 deletions
|
|
@ -51,4 +51,24 @@ impl Users {
|
|||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_by_email(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
email: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/users/get_one_by_email.sql", email)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_by_username(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
username: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/users/get_one_by_username.sql", username)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue