diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-01-12 12:16:54 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-01-12 12:16:54 +0100 |
commit | 35112f2357d6510a889c8e20604b11a2c0acf342 (patch) | |
tree | 633df7fa174d885925e4445b3e68b164047161ef /src/models | |
parent | 49a06ccbf087c4ed0db3d61f3ac4892f45858ce1 (diff) | |
download | rocket-blog-35112f2357d6510a889c8e20604b11a2c0acf342.tar.gz rocket-blog-35112f2357d6510a889c8e20604b11a2c0acf342.tar.bz2 rocket-blog-35112f2357d6510a889c8e20604b11a2c0acf342.zip |
Implement deleting posts.
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/post.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/models/post.rs b/src/models/post.rs index 922dbca..3dd0879 100644 --- a/src/models/post.rs +++ b/src/models/post.rs @@ -53,4 +53,11 @@ impl Post { .execute(&*conn) .expect("Error saving post."); } + + pub fn delete(post_id: i32, conn: utils::DbConn) { + use ::schema::posts::dsl::*; + diesel::delete(posts.filter(id.eq(post_id))) + .execute(&*conn) + .expect(&format!("Could not delete post with id {}", post_id)); + } } |