MongoDB request DSL • opensavvy.ktmongo.dsl.query • UpdateQuery • setIf
setIf¶
Replaces the value of a field with the specified value, if condition is true.
If condition is false, this operator does nothing.
Example¶
class User(
val name: String?,
val age: Int,
)
collection.filter {
User::name eq "foo"
}.updateMany {
User::age.setIf(someComplexOperation, 18)
}
External resources¶
See also¶
UpsertQuery.setOnInsertOnly set if a new document is created.
Replaces the value of a field with the specified value, if condition is true.
If condition is false, this operator does nothing.
Example¶
class User(
val name: String?,
val age: Int,
)
collection.filter {
User::name eq "foo"
}.updateMany {
User::age.setIf(someComplexOperation, 18)
}
External resources¶
See also¶
UpsertQuery.setOnInsertOnly set if a new document is created.