1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use mongodb::db::ThreadedDatabase;
use bson::Document;
use mongodb::coll::options::UpdateOptions;

impl super::Database {

    pub fn update_many(
        &self,
        collection: String,
        filter: Document,
        update: Document,
        options: Option<UpdateOptions>,
    ) -> Result<i32,String>
    {
        let collection = self.db.get().unwrap().collection(&collection);

        match collection.update_many(
            filter,
            update,
            options
        ) {
            Ok(updated) => Ok(updated.modified_count),
            Err(e) => Err(e.to_string())
        }
    }
}