User profile edition

This commit is contained in:
Bat
2018-05-12 16:30:14 +01:00
parent 3d5d03dc08
commit ea08718c23
4 changed files with 65 additions and 0 deletions
+11
View File
@@ -76,6 +76,17 @@ impl User {
.expect("Error saving new user")
}
pub fn update(&self, conn: &PgConnection, name: String, email: String, summary: String) -> User {
diesel::update(self)
.set((
users::display_name.eq(name),
users::email.eq(email),
users::summary.eq(summary),
)).load::<User>(conn)
.expect("Couldn't update user")
.into_iter().nth(0).unwrap()
}
pub fn get(conn: &PgConnection, id: i32) -> Option<User> {
users::table.filter(users::id.eq(id))
.limit(1)