1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-08-10 21:19:09 +00:00

Merge pull request #217 from janost/refactor-device-save

Device::save() should return QueryResult instead of bool
This commit is contained in:
Daniel García 2018-10-14 17:35:59 +02:00 committed by GitHub
commit faec050a6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 18 deletions

View file

@ -112,15 +112,11 @@ use db::schema::devices;
/// Database methods
impl Device {
pub fn save(&mut self, conn: &DbConn) -> bool {
pub fn save(&mut self, conn: &DbConn) -> QueryResult<()> {
self.updated_at = Utc::now().naive_utc();
match diesel::replace_into(devices::table)
.values(&*self)
.execute(&**conn) {
Ok(1) => true, // One row inserted
_ => false,
}
diesel::replace_into(devices::table)
.values(&*self).execute(&**conn).and(Ok(()))
}
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {