Skip to content

UpdatePipelineOperations

Interface grouping MongoDB operations allowing to update existing information using aggregation pipelines.

Inheritors

Properties

context

@LowLevelApi



abstract val context: BsonContext

Functions

updateManyWithPipeline

Updates all documents that match filter according to the update pipeline.

Example
class User(
    val name: String,
    val age: Int,
)

collection.updateManyWithPipeline(
    filter = {
        User::name eq "Patrick"
    }
) {
    set {
        User::age set 15
    }
}
External resources

Parameters

  • filter: Optional filter to select which documents are updated. If no filter is specified, all documents are updated.

See also

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

upsertOneWithPipeline

Updates a single document that matches filter according to the update pipeline.

If multiple documents match filter, only the first one is updated.

If no documents match filter, a new one is created.

Example
class User(
    val name: String,
    val age: Int,
)

collection.upsertOneWithPipeline(
    filter = {
         User::name eq "Patrick"
    }
) {
    set {
        User::age set 15
    }
}
External resources

See also