diff options
Diffstat (limited to 'server/src/models')
-rw-r--r-- | server/src/models/user.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/src/models/user.rs b/server/src/models/user.rs index 38ec121..dd96f90 100644 --- a/server/src/models/user.rs +++ b/server/src/models/user.rs @@ -81,6 +81,23 @@ impl User { Ok(rec) } + pub async fn find_by_id(user_id: i32) -> Result<UserList, AppError> { + let pool = unsafe { get_client() }; + + let rec = sqlx::query_as!( + UserList, + r#" + SELECT id, email, is_staff FROM "users" + WHERE id = $1 + "#, + user_id + ) + .fetch_one(pool) + .await?; + + Ok(rec) + } + pub async fn list() -> Result<Vec<UserList>, AppError> { let pool = unsafe { get_client() }; let rows = sqlx::query_as!(UserList, r#"SELECT id, email, is_staff FROM users"#) |