aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-07-31 20:12:07 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-07-31 20:12:07 +0200
commita1bba63fae68e7e6a680b14b674d9c47dfcf4862 (patch)
tree6484735d42d923aad111766b6c6a3cf755e92377 /src/models
parent706a887f9b5641d3aa609a0a8b4d3d68b659f653 (diff)
downloadrocket-blog-a1bba63fae68e7e6a680b14b674d9c47dfcf4862.tar.gz
rocket-blog-a1bba63fae68e7e6a680b14b674d9c47dfcf4862.tar.bz2
rocket-blog-a1bba63fae68e7e6a680b14b674d9c47dfcf4862.zip
Implement deleting 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 0345e92..9587fd3 100644
--- a/src/models/user.rs
+++ b/src/models/user.rs
@@ -38,6 +38,11 @@ impl User {
.get_result(&*conn)
}
+ pub fn delete(user_id: i32, conn: utils::DbConn) -> QueryResult<User> {
+ use ::schema::users::dsl::*;
+ diesel::delete(users.filter(id.eq(user_id))).get_result::<User>(&*conn)
+ }
+
pub fn realname(&self) -> String {
self.realname.as_ref().unwrap_or(&String::new()).clone()
}