aboutsummaryrefslogtreecommitdiff
path: root/src/db/models/folder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/models/folder.rs')
-rw-r--r--src/db/models/folder.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/db/models/folder.rs b/src/db/models/folder.rs
index d51e71b4..33976203 100644
--- a/src/db/models/folder.rs
+++ b/src/db/models/folder.rs
@@ -70,8 +70,8 @@ use crate::error::MapResult;
/// Database methods
impl Folder {
- pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
- User::update_uuid_revision(&self.user_uuid, conn);
+ pub async fn save(&mut self, conn: &DbConn) -> EmptyResult {
+ User::update_uuid_revision(&self.user_uuid, conn).await;
self.updated_at = Utc::now().naive_utc();
db_run! { conn:
@@ -105,9 +105,9 @@ impl Folder {
}
}
- pub fn delete(&self, conn: &DbConn) -> EmptyResult {
- User::update_uuid_revision(&self.user_uuid, conn);
- FolderCipher::delete_all_by_folder(&self.uuid, conn)?;
+ pub async fn delete(&self, conn: &DbConn) -> EmptyResult {
+ User::update_uuid_revision(&self.user_uuid, conn).await;
+ FolderCipher::delete_all_by_folder(&self.uuid, conn).await?;
db_run! { conn: {
diesel::delete(folders::table.filter(folders::uuid.eq(&self.uuid)))
@@ -116,14 +116,14 @@ impl Folder {
}}
}
- pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult {
- for folder in Self::find_by_user(user_uuid, conn) {
- folder.delete(conn)?;
+ pub async fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult {
+ for folder in Self::find_by_user(user_uuid, conn).await {
+ folder.delete(conn).await?;
}
Ok(())
}
- pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> {
+ pub async fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> {
db_run! { conn: {
folders::table
.filter(folders::uuid.eq(uuid))
@@ -133,7 +133,7 @@ impl Folder {
}}
}
- pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
+ pub async fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
db_run! { conn: {
folders::table
.filter(folders::user_uuid.eq(user_uuid))
@@ -145,7 +145,7 @@ impl Folder {
}
impl FolderCipher {
- pub fn save(&self, conn: &DbConn) -> EmptyResult {
+ pub async fn save(&self, conn: &DbConn) -> EmptyResult {
db_run! { conn:
sqlite, mysql {
// Not checking for ForeignKey Constraints here.
@@ -167,7 +167,7 @@ impl FolderCipher {
}
}
- pub fn delete(self, conn: &DbConn) -> EmptyResult {
+ pub async fn delete(self, conn: &DbConn) -> EmptyResult {
db_run! { conn: {
diesel::delete(
folders_ciphers::table
@@ -179,7 +179,7 @@ impl FolderCipher {
}}
}
- pub fn delete_all_by_cipher(cipher_uuid: &str, conn: &DbConn) -> EmptyResult {
+ pub async fn delete_all_by_cipher(cipher_uuid: &str, conn: &DbConn) -> EmptyResult {
db_run! { conn: {
diesel::delete(folders_ciphers::table.filter(folders_ciphers::cipher_uuid.eq(cipher_uuid)))
.execute(conn)
@@ -187,7 +187,7 @@ impl FolderCipher {
}}
}
- pub fn delete_all_by_folder(folder_uuid: &str, conn: &DbConn) -> EmptyResult {
+ pub async fn delete_all_by_folder(folder_uuid: &str, conn: &DbConn) -> EmptyResult {
db_run! { conn: {
diesel::delete(folders_ciphers::table.filter(folders_ciphers::folder_uuid.eq(folder_uuid)))
.execute(conn)
@@ -195,7 +195,7 @@ impl FolderCipher {
}}
}
- pub fn find_by_folder_and_cipher(folder_uuid: &str, cipher_uuid: &str, conn: &DbConn) -> Option<Self> {
+ pub async fn find_by_folder_and_cipher(folder_uuid: &str, cipher_uuid: &str, conn: &DbConn) -> Option<Self> {
db_run! { conn: {
folders_ciphers::table
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
@@ -206,7 +206,7 @@ impl FolderCipher {
}}
}
- pub fn find_by_folder(folder_uuid: &str, conn: &DbConn) -> Vec<Self> {
+ pub async fn find_by_folder(folder_uuid: &str, conn: &DbConn) -> Vec<Self> {
db_run! { conn: {
folders_ciphers::table
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))