I have a database of human documents. Each has a field called photos, which is an array of photo documents. I would like to add a new βcheckedβ flag to each of the photo documents and initialize it to false.
This is the query I'm trying to use:
db.person.update({ "_id" : { $exists : true } }, {$set : {photos.reviewed : false} }, false, true)
However, I get the following error:
SyntaxError: missing : after property id (shell):1
Is this possible, and if so, what am I doing wrong in my update?
Here is a complete example of a person document:
{ "_class" : "com.foo.Person", "_id" : "2894", "name" : "Pixel Spacebag", "photos" : [ { "_id" : null, "thumbUrl" : "http://site.com/a_s.jpg", "fullUrl" : "http://site.com/a.jpg" }, { "_id" : null, "thumbUrl" : "http://site.com/b_s.jpg", "fullUrl" : "http://site.com/b.jpg" }] }
Bonus karma for anyone who can tell me what is cleaner, why update "all documents" without using the request { "_id" : { $exists : true } }
Michael peterson
source share