I've got 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 the lastModified of one of the sets in the array? According to mongodb I can only update a document using the document's unique ID, but that's at the top level. How can I say update this lastModified
field in this set of Peers
with a uniquePeer
of 1 in this document?
Edit:
Content.update({"_id" : "mongoId", "Peers.uniquePeer" : "1"},{$set : {"Peers.$.lastModified" : "Now"}})
I still get a "Not permitted. Untrusted code may only update documents by ID."