awesome-compose/react-rust-postgres/backend/src/user.rs
Jérémie Drouet b73e252639 react-rust-postgres: add connection to postgres with migrations
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
2020-03-26 10:39:45 +01:00

19 lines
394 B
Rust

#![allow(proc_macro_derive_resolution_fallback)]
use diesel;
use diesel::prelude::*;
use super::schema::users;
#[derive(Queryable, AsChangeset, Serialize, Deserialize)]
#[table_name = "users"]
pub struct User {
pub id: i32,
pub login: String,
}
impl User {
pub fn all(connection: &PgConnection) -> QueryResult<Vec<User>> {
users::table.load::<User>(&*connection)
}
}