BulkWrite
class BulkWrite<Document : Any> : AbstractBsonNode, Command, CompoundNode<AvailableInBulkWrite<Document>> (source)
Performing multiple write operations in a single request.
Example
users.bulkWrite {
updateOne({ User::name eq "foo" }) {
User::age set 18
}
upsertOne({ User::name eq "bob" }) {
User::age setOnInsert 18
User::age inc 1
}
}
Content copied to clipboard
Filtered writes
If we have multiple writes that share a similar filter, we can extract it to be common between them.
users.bulkWrite {
updateOne({ User::name eq "foo" }) {
User::age set 18
}
filtered({ User::isAlive eq true }) {
updateMany({ User::name eq "bar" }) {
User::age inc 2
}
updateOne({ User::name eq "baz" }) {
User::age inc 1
}
}
}
Content copied to clipboard
To learn more, see filtered.
External resources
See also
Options
Functions
Link copied to clipboard
Adds a new Node into the current node.
Link copied to clipboard
Declares a filter that is shared between all children operations.
Link copied to clipboard
Inserts multiple documents in a single operation.
Link copied to clipboard
Writes the result of simplifying to a new Bson.
Link copied to clipboard
fun updateMany(options: UpdateOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, update: UpdateQuery<Document>.() -> Unit)
Link copied to clipboard
fun updateOne(options: UpdateOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, update: UpdateQuery<Document>.() -> Unit)
Link copied to clipboard
fun upsertOne(options: UpdateOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, update: UpsertQuery<Document>.() -> Unit)
Link copied to clipboard
Writes the result of simplifying this expression into writer.