mirror of
https://github.com/docker/awesome-compose.git
synced 2025-04-26 10:43:35 +02:00
react-rust-postgres: add connection to postgres with migrations
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
This commit is contained in:
parent
bed22c74f5
commit
b73e252639
12 changed files with 192 additions and 6 deletions
18
react-rust-postgres/backend/src/user.rs
Normal file
18
react-rust-postgres/backend/src/user.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
#![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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue