Skip to content

Commit be064e6

Browse files
committed
examples: Use diesel HasQuery trait
1 parent a847c60 commit be064e6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

examples/diesel-async-postgres/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ table! {
3838
}
3939
}
4040

41-
#[derive(serde::Serialize, Selectable, Queryable)]
41+
#[derive(serde::Serialize, HasQuery)]
4242
struct User {
4343
id: i32,
4444
name: String,
@@ -124,8 +124,7 @@ where
124124
async fn list_users(
125125
DatabaseConnection(mut conn): DatabaseConnection,
126126
) -> Result<Json<Vec<User>>, (StatusCode, String)> {
127-
let res = users::table
128-
.select(User::as_select())
127+
let res = User::query()
129128
.load(&mut conn)
130129
.await
131130
.map_err(internal_error)?;

examples/diesel-postgres/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ table! {
3535
}
3636
}
3737

38-
#[derive(serde::Serialize, Selectable, Queryable)]
38+
#[derive(serde::Serialize, HasQuery)]
3939
struct User {
4040
id: i32,
4141
name: String,
@@ -112,7 +112,7 @@ async fn list_users(
112112
) -> Result<Json<Vec<User>>, (StatusCode, String)> {
113113
let conn = pool.get().await.map_err(internal_error)?;
114114
let res = conn
115-
.interact(|conn| users::table.select(User::as_select()).load(conn))
115+
.interact(|conn| User::query().load(conn))
116116
.await
117117
.map_err(internal_error)?
118118
.map_err(internal_error)?;

0 commit comments

Comments
 (0)