1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use bson::Document; use mongodb::options::DeleteOptions; impl super::Database { pub fn delete_many( &self, collection: &str, filter: Document, write_concern: Option<DeleteOptions>, ) -> Result<i64, String> { let collection = self.db.collection(&String::from(collection)); match collection.delete_many(filter, write_concern) { Ok(deleted) => Ok(deleted.deleted_count), Err(e) => Err(e.to_string()), } } }