I have been studying how to use Mongodb, and have been stuck at querying data in embedded document for hours. I found example on Mongodb’s website here: http://www.mongodb.org/display/DOCS/Schema+Design#SchemaDesign-EmbeddingandLinking
However, when I tried it with my own data such as
db.test.save({"name":"record", "items":[{"histPrices":[10,12],"name":"stuff"}]})
db.test.find({items.name:"stuff"})
It never finds anything, instead it is given me an error:
Fri Nov 2 14:24:09 SyntaxError: missing : after property id (shell):1
Anyone has any tips on this?
I’m not sure why you are using
histPrices.name. But if you’re using dot-notation, you should enclose the complex name in quotes.