Created
January 31, 2017 04:38
-
-
Save zrneely/2af5bc84d5e61c777d8bf700bc8f9f12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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