|
|
@ -81,13 +81,14 @@ impl Folder {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn delete(self, conn: &DbConn) -> bool {
|
|
|
|
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
|
|
|
|
match diesel::delete(folders::table.filter(
|
|
|
|
FolderCipher::delete_all_by_folder(&self.uuid, &conn)?;
|
|
|
|
folders::uuid.eq(self.uuid)))
|
|
|
|
|
|
|
|
.execute(&**conn) {
|
|
|
|
diesel::delete(
|
|
|
|
Ok(1) => true, // One row deleted
|
|
|
|
folders::table.filter(
|
|
|
|
_ => false,
|
|
|
|
folders::uuid.eq(self.uuid)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
).execute(&**conn).and(Ok(()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> {
|
|
|
|
pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> {
|
|
|
@ -123,6 +124,12 @@ impl FolderCipher {
|
|
|
|
).execute(&**conn).and(Ok(()))
|
|
|
|
).execute(&**conn).and(Ok(()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn delete_all_by_folder(folder_uuid: &str, conn: &DbConn) -> QueryResult<()> {
|
|
|
|
|
|
|
|
diesel::delete(folders_ciphers::table
|
|
|
|
|
|
|
|
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
|
|
|
|
|
|
|
|
).execute(&**conn).and(Ok(()))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn find_by_folder_and_cipher(folder_uuid: &str, cipher_uuid: &str, conn: &DbConn) -> Option<Self> {
|
|
|
|
pub fn find_by_folder_and_cipher(folder_uuid: &str, cipher_uuid: &str, conn: &DbConn) -> Option<Self> {
|
|
|
|
folders_ciphers::table
|
|
|
|
folders_ciphers::table
|
|
|
|
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
|
|
|
|
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
|
|
|
|