Mongodb - will $addToSet create the field?
mongodb
Solution
Yes, it will create. But the proper syntax is:
db.collection.update({id: <id>}, {$addToSet: {<field2>: <value>}})
Problem
Will an array update using $addToSet create the field if it doesn't exist? In other words, if `field2` in the line below does not exist, will it be created by this command: ``` db.collection.update({id: <id>}, {<field2>: {$addToSet: <value>}}) ```