pub trait CollectionExt {
    // Required method
    fn bulk_update<'life0, 'life1, 'async_trait, V, U>(
        &'life0 self,
        db: &'life1 Database,
        updates: V
    ) -> Pin<Box<dyn Future<Output = Result<BulkUpdateResult>> + Send + 'async_trait>>
       where V: 'async_trait + Send + Sync + Borrow<Vec<U>>,
             U: 'async_trait + Send + Sync + Borrow<BulkUpdate>,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

MongODM-provided utilities functions on mongodb::Collection<M>.

Required Methods§

source

fn bulk_update<'life0, 'life1, 'async_trait, V, U>( &'life0 self, db: &'life1 Database, updates: V ) -> Pin<Box<dyn Future<Output = Result<BulkUpdateResult>> + Send + 'async_trait>>
where V: 'async_trait + Send + Sync + Borrow<Vec<U>>, U: 'async_trait + Send + Sync + Borrow<BulkUpdate>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Apply multiple update operations in bulk.

This will be removed once support for bulk update is added to the official driver. see for tracking progress on this feature in the official driver.

Example
use mongodm::prelude::*;
/* ... */
let db: mongodb::Database; /* exists */
let collection = db.collection::<User>("user");
/* ... */
let bulk_update_res = collection
    .bulk_update(&db, &vec![
        &BulkUpdate {
            query: doc! { f!(name in User): "Dane" },
            update: doc! { Set: { f!(age in User): 12 } },
            options: None,
        },
        &BulkUpdate {
            query: doc! { f!(name in User): "David" },
            update: doc! { Set: { f!(age in User): 30 } },
            options: None,
        },
    ])
    .await
    .unwrap();
assert_eq!(bulk_update_res.nb_affected, 2);
assert_eq!(bulk_update_res.nb_modified, 2);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<M: Send + Sync> CollectionExt for Collection<M>

source§

fn bulk_update<'life0, 'life1, 'async_trait, V, U>( &'life0 self, db: &'life1 Database, updates: V ) -> Pin<Box<dyn Future<Output = Result<BulkUpdateResult>> + Send + 'async_trait>>
where V: 'async_trait + Send + Sync + Borrow<Vec<U>>, U: 'async_trait + Send + Sync + Borrow<BulkUpdate>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§