aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml7
-rw-r--r--src/main.rs1
-rw-r--r--src/models/post.rs7
-rw-r--r--src/utils/mod.rs7
4 files changed, 10 insertions, 12 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1f202ce..ccbc097 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,11 +6,10 @@ authors = ["Harald Eilertsen <haraldei@anduin.net>"]
[dependencies]
rocket = "0.3.6"
rocket_codegen = "0.3.6"
-diesel = { version = "0.16.0", features = ["postgres"] }
-diesel_codegen = { version = "0.16.0", features = ["postgres"] }
+diesel = { version = "1.1.0", features = ["postgres"] }
dotenv = "0.10.1"
-r2d2 = "0.7.4"
-r2d2-diesel = "0.16.0"
+r2d2 = "0.8.2"
+r2d2-diesel = "1.0.0"
bart = "0.1.4"
bart_derive = "0.1.4"
serde = "1.0"
diff --git a/src/main.rs b/src/main.rs
index 4876b35..424dbde 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,6 @@
#![plugin(rocket_codegen)]
#[macro_use] extern crate bart_derive;
-#[macro_use] extern crate diesel_codegen;
#[macro_use] extern crate diesel;
#[macro_use] extern crate serde_derive;
diff --git a/src/models/post.rs b/src/models/post.rs
index 3dd0879..17ac74a 100644
--- a/src/models/post.rs
+++ b/src/models/post.rs
@@ -1,6 +1,6 @@
use schema::posts;
use diesel::prelude::*;
-use diesel::{self, ExecuteDsl};
+use diesel;
use utils;
#[derive(AsChangeset, FromForm, Identifiable, Serialize, Queryable)]
@@ -40,8 +40,9 @@ impl Post {
}
pub fn create(new_post: &NewPost, conn: utils::DbConn) {
- diesel::insert(new_post)
- .into(posts::table)
+ use ::schema::posts::dsl::*;
+ diesel::insert_into(posts)
+ .values(new_post)
.execute(&*conn)
.expect("Error saving post.");
}
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 495440a..57975bc 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -1,16 +1,15 @@
-use diesel::pg::PgConnection;
-use std::fmt::Display;
+use diesel::PgConnection;
use r2d2;
use r2d2_diesel::ConnectionManager;
+use std::fmt::Display;
// An alias to the type for a pool of Diesel PostgreSql connections.
type Pool = r2d2::Pool<ConnectionManager<PgConnection>>;
/// Initializes a database pool.
pub fn init_db_pool<'a>(dburl: &'a str) -> Pool {
- let config = r2d2::Config::default();
let manager = ConnectionManager::<PgConnection>::new(dburl);
- r2d2::Pool::new(config, manager).expect("db pool")
+ r2d2::Pool::builder().build(manager).expect("db pool")
}
use std::ops::Deref;