BulkWrite
class BulkWrite<Document : Any> : Command, AbstractBsonNode, 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
Properties
Link copied to clipboard
The context used to generate this expression.
Link copied to clipboard
val operations: ERROR CLASS: Symbol not found for Sequence<opensavvy/ktmongo/dsl/command/AvailableInBulkWrite<Document>>
Link copied to clipboard
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
fun replaceOne(options: ReplaceOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, document: Document)
Link copied to clipboard
fun repsertOne(options: ReplaceOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, document: Document)
Link copied to clipboard
Returns a simplified (but equivalent) expression to the current expression.
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.