Skip to content

UpdatePipelineOperations

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

Inheritors

Properties

context

abstract val context: BsonContext

The full BSON configuration, used by the DSL to generate queries.

For more information, see BsonContext.

factory

abstract val factory: BsonFactory

The BsonFactory used to serialize and deserialize values.

This property stores all serialization configurations and allows creating custom BSON objects.

For more information, see BsonFactory.

objectIdGenerator

The algorithm used to generate new ObjectId instances.

For more information, see ObjectIdGenerator.

propertyNameStrategy

The strategy used to convert property names to BSON document keys.

For more information, see PropertyNameStrategy.

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