MongoDB: cannot upsert if query object and update object contain a same property , 'Cannot apply $addToSet modifier to non-array'
问题 I want to execute a complex upsert, made by the following elements: query on a field f by regex update of the same field f (that is specified in the query object too) Like this: db.coll.update({ prop: /valueprop/i } , { $addToSet:{ prop:'a value' } } , true, false) My expectation would be that if the document does not exist in the collection it is inserted with prop field equals to 'a value'; in other words it should insert a document with value of prop field that is the one specified in the