Skip to content

Instantly share code, notes, and snippets.

@zrneely
Created January 31, 2017 04:38
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 zrneely/2af5bc84d5e61c777d8bf700bc8f9f12 to your computer and use it in GitHub Desktop.
Save zrneely/2af5bc84d5e61c777d8bf700bc8f9f12 to your computer and use it in GitHub Desktop.
/// Inserts a new user.
pub fn create_user<'a>(conn: &PgConnection, name: &'a str, admin: bool)
-> Result<PgConnection, MyErrorType> {
use self::schema::users;
let new_user = NewUser {
name: name,
karma: 0,
admin: admin,
};
Ok(diesel::insert(&new_user).into(users::table).get_result(conn)?)
}
// Elsewhere: impl From<diesel::result::Error> for MyErrorType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment