filtered

fun filtered(filter: FilterQuery<Document>.() -> Unit, operations: BulkWrite<Document>.() -> Unit)(source)

Declares a filter that is shared between all children operations.

Example

Sometimes, we have multiple operations in a single bulk write that share the same filter. This method allows to declare it a single time.

users.bulkWrite {
filtered({ User::isAlive eq true }) {
updateOne { /* … */}
updateOne { /* … */}
}
}