setUnless
Replaces the value of a field with the specified value, if condition is false
.
If condition is true
, this operator does nothing.
Example
class User(
val name: String?,
val age: Int,
)
collection.filter {
User::name eq "foo"
}.updateMany {
User::age.setUnless(someComplexOperation, 18)
}
Content copied to clipboard
External resources
See also
Only set if a new document is created.