This is due to how the dsl is implemented and the chaining of $each
. The core issue is I dont think $addToSet merges as expected::
val setOps1 = $addToSet("appearsOn") $each(sourceToAppend:_*)
val setOps2 = $addToSet("hasElements") $each(elementsToAppend:_*)
setOps1 ++ setOps2
DBObject = { "$addToSet" : { "hasElements" : { "$each" : [ "another" , "list"]}}}
Seems MongoDBObject ++ does not recursively merge.