aboutsummaryrefslogtreecommitdiff
path: root/src/db/models/collection.rs
diff options
context:
space:
mode:
authorjanost <[email protected]>2018-10-06 23:56:05 +0200
committerjanost <[email protected]>2018-10-07 11:06:11 +0200
commit5292d38c739db270fc9b3f41a8d84b9699ffbb30 (patch)
treeeef75605c8849190b23e08d16d9bb9148789a295 /src/db/models/collection.rs
parent1049646e27f481392a3582041df6e482128be594 (diff)
downloadvaultwarden-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.rs18
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<()> {