diff options
author | janost <[email protected]> | 2018-10-06 23:56:05 +0200 |
---|---|---|
committer | janost <[email protected]> | 2018-10-07 11:06:11 +0200 |
commit | 5292d38c739db270fc9b3f41a8d84b9699ffbb30 (patch) | |
tree | eef75605c8849190b23e08d16d9bb9148789a295 /src/db/models/collection.rs | |
parent | 1049646e27f481392a3582041df6e482128be594 (diff) | |
download | vaultwarden-5292d38c739db270fc9b3f41a8d84b9699ffbb30.tar.gz vaultwarden-5292d38c739db270fc9b3f41a8d84b9699ffbb30.zip |
CollectionCipher::save() and delete() should return QueryResult instead of bool
Diffstat (limited to 'src/db/models/collection.rs')
-rw-r--r-- | src/db/models/collection.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/db/models/collection.rs b/src/db/models/collection.rs index ddc4d2e9..bcbacbe4 100644 --- a/src/db/models/collection.rs +++ b/src/db/models/collection.rs @@ -259,25 +259,19 @@ pub struct CollectionCipher { /// Database methods impl CollectionCipher { - pub fn save(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> bool { - match diesel::replace_into(ciphers_collections::table) + pub fn save(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> QueryResult<()> { + diesel::replace_into(ciphers_collections::table) .values(( ciphers_collections::cipher_uuid.eq(cipher_uuid), ciphers_collections::collection_uuid.eq(collection_uuid), - )).execute(&**conn) { - Ok(1) => true, // One row inserted - _ => false, - } + )).execute(&**conn).and(Ok(())) } - pub fn delete(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> bool { - match diesel::delete(ciphers_collections::table + pub fn delete(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> QueryResult<()> { + diesel::delete(ciphers_collections::table .filter(ciphers_collections::cipher_uuid.eq(cipher_uuid)) .filter(ciphers_collections::collection_uuid.eq(collection_uuid))) - .execute(&**conn) { - Ok(1) => true, // One row deleted - _ => false, - } + .execute(&**conn).and(Ok(())) } pub fn delete_all_by_cipher(cipher_uuid: &str, conn: &DbConn) -> QueryResult<()> { |