aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-01-10 21:14:50 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-01-10 21:14:50 +0100
commitf6e51533077fa13515c40c0a869ab8c589ceb5d2 (patch)
tree366e071c56a413bf600c41e36f1e2f7a03e93df3
parent42413235bed80e9af6a9655dba504dbf2bdc572c (diff)
downloadrocket-blog-f6e51533077fa13515c40c0a869ab8c589ceb5d2.tar.gz
rocket-blog-f6e51533077fa13515c40c0a869ab8c589ceb5d2.tar.bz2
rocket-blog-f6e51533077fa13515c40c0a869ab8c589ceb5d2.zip
Make proper module of models
-rw-r--r--src/models/mod.rs3
-rw-r--r--src/models/post.rs (renamed from src/models.rs)8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/models/mod.rs b/src/models/mod.rs
new file mode 100644
index 0000000..0d38f29
--- /dev/null
+++ b/src/models/mod.rs
@@ -0,0 +1,3 @@
+pub mod post;
+pub use self::post::Post;
+pub use self::post::NewPost;
diff --git a/src/models.rs b/src/models/post.rs
index 33a5fe7..f7c35ac 100644
--- a/src/models.rs
+++ b/src/models/post.rs
@@ -1,4 +1,4 @@
-use super::schema::posts;
+use ::schema::posts;
use diesel::prelude::*;
use diesel::{self, ExecuteDsl};
@@ -20,7 +20,7 @@ pub struct NewPost {
impl Post {
pub fn get_all(conn: ::DbConn) -> Vec<Post> {
- use super::schema::posts::dsl::*;
+ use ::schema::posts::dsl::*;
posts.filter(published.eq(false))
.limit(5)
.load::<Post>(&*conn)
@@ -28,7 +28,7 @@ impl Post {
}
pub fn get(post_id: i32, conn: ::DbConn) -> Post {
- use super::schema::posts::dsl::*;
+ use ::schema::posts::dsl::*;
posts.find(post_id).get_result(&*conn)
.expect(&format!("Unable to find post with id={}", post_id))
}
@@ -41,7 +41,7 @@ impl Post {
}
pub fn update(_updated_post: &Post, _conn: ::DbConn) {
- //use super::schema::posts::dsl::*;
+ //use ::schema::posts::dsl::*;
//diesel::update(updated_post)
// .into(posts)