lundi 30 mars 2015

updating a subdocument inside nested array using $addToset followed by $pull


{"layers":[{"layer name":"layer1","layer_vals":[{"name":"val1","updated":"value"}]}]}


I have a JSON document like the one above.I wish to change the value of updated everytime an operation is performed on that subdocument.As can be seen the document is nested inside two arrays.I am planning to use a $addToSet to first add the new updated value and then do $pull to remove the old one.But I am getting an error saying I cannot perform both operation on same document.Is there any solution to this? Also any other suggestions on solving the above problem would be great too


Aucun commentaire:

Enregistrer un commentaire