Make mongo document delete_one function return the delete count

This commit is contained in:
Victor Mignot 2023-02-13 00:01:06 +01:00
parent de1eb03b13
commit af4573fc4b
No known key found for this signature in database
GPG key ID: FFE4EF056FB5E0D0

View file

@ -162,15 +162,14 @@ impl Client {
} }
} }
#[allow(dead_code)]
// TODO: Set true error handling // TODO: Set true error handling
pub async fn delete_one<T: YorokobotModel>(&self, document: Document) -> Result<(), ()> { pub async fn delete_one<T: YorokobotModel>(&self, document: Document) -> Result<u64, ()> {
match self match self
.get_typed_collection::<T>() .get_typed_collection::<T>()
.delete_one(document, None) .delete_one(document, None)
.await .await
{ {
Ok(_) => Ok(()), Ok(result) => Ok(result.deleted_count),
Err(_) => Err(()), Err(_) => Err(()),
} }
} }