pushEach
Adds multiple values at the end of the array.
Unlike addToSet, this operator always adds all values, even if they're already present in the array.
This is a convenience function for calling push multiple times.
Example
class User(
val name: String,
val age: Int,
val scores: List<Int>,
)
collection.updateOne(
filter = {
User::name eq "Bob"
},
update = {
User::scores pushEach listOf(100, 200)
}
)Content copied to clipboard
This will add 100 and 200 to the user's scores, even if they're already present.