user: get one by id

This commit is contained in:
Philippe Loctaux 2023-03-08 00:14:36 +01:00
parent 5404fb1cf8
commit e04de752ef
4 changed files with 111 additions and 0 deletions

View file

@ -41,4 +41,14 @@ impl Users {
Ok((query.rows_affected() == 1).then_some(()))
}
pub async fn get_one_by_id(
conn: impl SqliteExecutor<'_>,
id: &str,
) -> Result<Option<Self>, Error> {
sqlx::query_file_as!(Self, "queries/users/get_one_by_id.sql", id)
.fetch_optional(conn)
.await
.map_err(handle_error)
}
}