aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/post.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/post.rs')
-rw-r--r--src/models/post.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/models/post.rs b/src/models/post.rs
index be44dda..bde8e54 100644
--- a/src/models/post.rs
+++ b/src/models/post.rs
@@ -1,7 +1,7 @@
use diesel;
use diesel::prelude::*;
use schema::posts;
-use utils;
+use utils::DbConn;
#[derive(AsChangeset, FromForm, Identifiable, Serialize, Queryable)]
pub struct Post {
@@ -20,7 +20,7 @@ pub struct NewPost {
}
impl Post {
- pub fn get_all(conn: utils::DbConn) -> Vec<Post> {
+ pub fn get_all(conn: DbConn) -> Vec<Post> {
use schema::posts::dsl::*;
posts
.filter(published.eq(false))
@@ -29,7 +29,7 @@ impl Post {
.expect("Error loading posts")
}
- fn get_internal(post_id: i32, conn: &utils::DbConn) -> Post {
+ fn get_internal(post_id: i32, conn: &DbConn) -> Post {
use schema::posts::dsl::*;
posts
.find(post_id)
@@ -37,11 +37,11 @@ impl Post {
.expect(&format!("Unable to find post with id={}", post_id))
}
- pub fn get(post_id: i32, conn: utils::DbConn) -> Post {
+ pub fn get(post_id: i32, conn: DbConn) -> Post {
Post::get_internal(post_id, &conn)
}
- pub fn create(new_post: &NewPost, conn: utils::DbConn) {
+ pub fn create(new_post: &NewPost, conn: DbConn) {
use schema::posts::dsl::*;
diesel::insert_into(posts)
.values(new_post)
@@ -49,7 +49,7 @@ impl Post {
.expect("Error saving post.");
}
- pub fn update(updated_post: &Post, conn: utils::DbConn) {
+ pub fn update(updated_post: &Post, conn: DbConn) {
let p = Post::get_internal(updated_post.id, &conn);
diesel::update(&p)
.set(updated_post)
@@ -57,7 +57,7 @@ impl Post {
.expect("Error saving post.");
}
- pub fn delete(post_id: i32, conn: utils::DbConn) {
+ pub fn delete(post_id: i32, conn: DbConn) {
use schema::posts::dsl::*;
diesel::delete(posts.filter(id.eq(post_id)))
.execute(&*conn)