1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use mongodb::db::ThreadedDatabase; use bson::Document; use mongodb::common::WriteConcern; impl super::Database { pub fn delete_many( &self, collection: String, filter: Document, write_concern: Option<WriteConcern>, ) -> Result<i32,String> { let collection = self.db.get().unwrap().collection(&collection); match collection.delete_many( filter, write_concern ) { Ok(deleted) => Ok(deleted.deleted_count), Err(e) => Err(e.to_string()) } } }