MongoDB driver for Kotlin (synchronous) • opensavvy.ktmongo.sync.operations • UpdatePipelineOperations • updateOneWithPipeline
updateOneWithPipeline¶
Updates a single document that matches filter
according to the update
pipeline.
If multiple documents match filter
, only the first one found is updated.
Example¶
class User(
val name: String,
val age: Int,
)
collection.updateOneWithPipeline(
filter = {
User::name eq "Patrick"
}
) {
set {
User::age set 15
}
}
External resources¶
Parameters¶
- filter
-
Optional filter to select which document is updated. If no filter is specified, the first document found is updated.
See also¶
-
UpdatePipelineOperations.updateManyWithPipeline
Update multiple documents. -
UpdatePipelineOperations.upsertOneWithPipeline
Update a document, creating it if it doesn't exist.