setOnInsert
If an upsert operation results in an insert of a document, then this operator assigns the specified value to the field. If the update operation does not result in an insert, this operator does nothing.
Example
class User(
val name: String?,
val age: Int,
)
collection.filter {
User::name eq "foo"
}.upsertOne {
User::age setOnInsert 18
}
Content copied to clipboard
External resources
See also
Always set the value.