Skip to content

Instantly share code, notes, and snippets.

@stephanbuys
Created August 1, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanbuys/4b2c874b3731e7f93b2b4d021f8ddcff to your computer and use it in GitHub Desktop.
Save stephanbuys/4b2c874b3731e7f93b2b4d021f8ddcff to your computer and use it in GitHub Desktop.
fn create_post(conn: &PgConnection, title: &str, body: &str) -> Post {
use schema::posts;
let new_post = NewPost {
title: title,
body: body,
};
diesel::insert(&new_post).into(posts::table)
.get_result(conn)
.expect("Error saving new post")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment