fix: rewrite attachment deletion logic

This commit is contained in:
Paul Makles
2022-06-20 10:49:09 +01:00
parent ef757aa2fb
commit 7fc4fb2df7
6 changed files with 96 additions and 5 deletions
@@ -122,4 +122,27 @@ impl AbstractAttachment for MongoDb {
with: "attachment",
})
}
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()> {
self.col::<Document>(COL)
.update_many(
doc! {
"_id": {
"$in": ids
}
},
doc! {
"$set": {
"deleted": true
}
},
None,
)
.await
.map(|_| ())
.map_err(|_| Error::DatabaseError {
operation: "update",
with: "attachments",
})
}
}