aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-07-31 16:49:42 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-07-31 16:49:42 +0200
commit7f5e8887e9b1a90d1ed3dd31f053dadec4c75d94 (patch)
tree0a6464a7434a6c43ffb285d300cf9a999fc6d226 /src/models
parent6a5f1bd90e46c2bea7be73b512d5202954900cad (diff)
downloadrocket-blog-7f5e8887e9b1a90d1ed3dd31f053dadec4c75d94.tar.gz
rocket-blog-7f5e8887e9b1a90d1ed3dd31f053dadec4c75d94.tar.bz2
rocket-blog-7f5e8887e9b1a90d1ed3dd31f053dadec4c75d94.zip
Add view to list all users
Diffstat (limited to 'src/models')
-rw-r--r--src/models/user.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/models/user.rs b/src/models/user.rs
index 537dfe6..7f6fe88 100644
--- a/src/models/user.rs
+++ b/src/models/user.rs
@@ -13,6 +13,11 @@ pub struct User {
}
impl User {
+ pub fn all(conn: utils::DbConn) -> QueryResult<Vec<User>> {
+ use schema::users::dsl::*;
+ users.load::<User>(&*conn)
+ }
+
pub fn by_id(user_id: i32, conn: utils::DbConn) -> QueryResult<User> {
use schema::users::dsl::*;
users.filter(id.eq(user_id))