12

I have an entry in my database that looks like:

{
  "_id" : ObjectId("4e93ace3f8208ca743000004"),
  "title" : "Entry",
  "domain" : {
    "_id" : ObjectId("4e9305d5f8208cab43000001"),
    "name" : "Google"
  }
}

To query for that particular entry (or entries that use the same domain) it looks like I'm supposed to query using:

db.entries.find({domain._id : ObjectId("4e9305d5f8208cab43000001")})

This however produces an error:

SyntaxError: missing : after property id (shell):1

What am I doing wrong in my query? Secondarily, how can I branch this out to PHP?

1 Answer 1

24

You will need to have the field name in quotes, eg:

db.entries.find({ "domain._id" : ... })
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.