MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.operators • ConditionalValueOperators • cond
cond¶
Decides between two values
depending on the evaluation of a boolean value.
Example¶
class User(
val name: String,
val score: Int,
val multiplier: Int,
)
users.updateManyWithPipeline {
set {
User::score set cond(
condition = of(User::multiplier) gt of(2),
ifTrue = of(User::score) * of(User::multiplier),
ifFalse = of(User::score)
)
}
}
External resources¶
See also¶
ConditionalValueOperators.switch
Specify multiple conditions.