I have a document structure like this:
Content { _id: "mongoId" Title: "Test", Age: "5", Peers: [{uniquePeer: "1", Name: "Testy Test", lastModified: "Never"}, {uniquePeer: "2", Name: "Test Tester", lastModified: "Never"}] }
So Peers is an array that has a unique identifier. How can I update lastModified of one of the sets in an array? According to mongodb, I can only update the document using the unique identifier of the document, but at the top level. How can I say update this lastModified field in this Peers set with uniquePeer from 1 in this document?
Edit:
Content.update({"_id" : "mongoId", "Peers.uniquePeer" : "1"},{$set : {"Peers.$.lastModified" : "Now"}})
I still get the message "Not Allowed. Invalid code can only update documents by ID."
Joshua terrill
source share