I am trying to update the following document in Mongodb.
doc = { id : 10 , graph :[{userId:1,children:[2]},{userId:2,children:[]}]}
db.test.insert(doc)
then I perform two updates:
db.test.update( {'id':10,'graph.userId' : 1}, { $push:{'graph.$.children':10}})
db.test.update( {'id':10,'graph.userId' : 1},{ $push:{'graph':{'userId':10,'children':[]}}})
(Saddly :
db.test.update( {'id':10,'graph.userId' : 1},{ $push:{'graph.$.children':10},$push:{'graph':{'userId':10,'children':[]}}})
does not work)
Is there a way to update these simultaneously ?
Thanks a lot