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