I'm wondering if $concatArrays
in the update section of findAndModify
will copy the source array, add the new elements to it and save the result to the target array or will it just append the new elements to the existing array without the mentioned copy.
To illustrate it better, here is an example:
db.myCollection.findAndModify ( { _id: 2 },
[ { $set: { myArray: { $concatArrays: [ "$myArray", [ 1, 2 ] ] } } } ]
)
Is Mongo smart enough o simply append [1, 2]
to myArray
without copying myArray
in the first place?