diff options
Diffstat (limited to 'server/src')
| -rw-r--r-- | server/src/models/user.rs | 10 | ||||
| -rw-r--r-- | server/src/routes/user.rs | 4 | 
2 files changed, 10 insertions, 4 deletions
diff --git a/server/src/models/user.rs b/server/src/models/user.rs index 72fd56a..08514a8 100644 --- a/server/src/models/user.rs +++ b/server/src/models/user.rs @@ -10,6 +10,12 @@ pub struct User {      password: String,  } +#[derive(Deserialize, Serialize)] +pub struct UserList { +    id: i32, +    email: String, +} +  impl User {      pub async fn create(user: User) -> Result<i32, AppError> {          let pool = unsafe { get_client() }; @@ -28,9 +34,9 @@ impl User {          Ok(rec.id)      } -    pub async fn list() -> Result<Vec<User>, AppError> { +    pub async fn list() -> Result<Vec<UserList>, AppError> {          let pool = unsafe { get_client() }; -        let rows = sqlx::query_as!(User, r#"SELECT id, email, password FROM users"#) +        let rows = sqlx::query_as!(UserList, r#"SELECT id, email FROM users"#)              .fetch_all(pool)              .await?; diff --git a/server/src/routes/user.rs b/server/src/routes/user.rs index f155f27..1b43e01 100644 --- a/server/src/routes/user.rs +++ b/server/src/routes/user.rs @@ -1,12 +1,12 @@  use crate::errors::AppError; -use crate::models::user::User; +use crate::models::user::{User, UserList};  use axum::{routing::get, Json, Router};  pub fn create_route() -> Router {      Router::new().route("/", get(list_users))  } -async fn list_users() -> Result<Json<Vec<User>>, AppError> { +async fn list_users() -> Result<Json<Vec<UserList>>, AppError> {      let users = User::list().await?;      Ok(Json(users))  |