Added a transaction for deleting all

This commit is contained in:
2023-07-19 14:56:07 +03:00
parent 255a794b0f
commit ff6dcf6dfe
3 changed files with 21 additions and 10 deletions

View File

@ -79,7 +79,7 @@ impl Entity {
/// Deletes all the user's accounts from DB
#[inline]
pub async fn delete_all(user_id: u64, db: &DatabaseConnection) -> crate::Result<()> {
pub async fn delete_all(user_id: u64, db: &impl ConnectionTrait) -> crate::Result<()> {
Self::delete_many()
.filter(Column::UserId.eq(user_id))
.exec(db)

View File

@ -33,7 +33,7 @@ impl Entity {
}
/// Removes a master password of the user from the database
pub async fn remove(user_id: u64, db: &DatabaseConnection) -> Result<(), DbErr> {
pub async fn remove(user_id: u64, db: &impl ConnectionTrait) -> Result<(), DbErr> {
Self::delete_by_id(user_id).exec(db).await?;
Ok(())
}