HasSet¶
Pipeline implementing the $set stage.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract val context: BsonContext
The context used to generate this pipeline.
Functions¶
set¶
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
-
block: The block defining the fields to set.
-
SetStageOperators.setOverwrite the value of a field. -
SetStageOperators.setIfOverwrite the value of a field if a condition is met. -
SetStageOperators.setUnlessOverwrite the value of a field if a condition is not met. -
SetStageOperators.excludeRemove a field.
toString¶
unsafeCast¶
abstract fun <New : Any> unsafeCast(): Pipeline<New>
Changes the type of the returned document, with no type-safety.
withStage¶
@DangerousMongoApi
@LowLevelApi
abstract fun withStage(stage: BsonNode): Pipeline<Document>
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.