Skip to content

HasSet

interface HasSet<Document : Any> : Pipeline<Document> 

Pipeline implementing the $set stage.

Inheritors

Properties

context

The context used to generate this pipeline.

Functions

set

open fun <Out : Any> set(block: SetStageOperators<Document, Out>.() -> Unit): Pipeline<Out>

Adds new fields to documents, or overwrites existing fields.

See $project to learn more about their differences.

Example

class User(
    val _id: ObjectId,
    val name: String,
    val age: Int,
    val isAdult: Boolean? = null,
)

users.aggregate()
    .set {
        User::isAdult set (User::age gte 18)
    }

External resources

Parameters

toString

abstract override fun toString(): String

JSON representation of this pipeline.

unsafeCast

abstract fun <New : Any> unsafeCast(): Pipeline<New>

Changes the type of the returned document, with no type-safety.

withStage

Creates a new pipeline that expands on the current one by adding stage.

writeTo

@LowLevelApi
abstract fun writeTo(writer: BsonValueWriter)

Writes the entire pipeline into writer.