I’m trying to query through a somewhat simple collection with the following structure:
{
"name":[
{
"something":"",
"somethingelse":[
{
"name":"John",
"city":"NY"
}
]}]}
I have tried to search the value "city" with the dot notation but no success.
2
Answers
You can call the data and store it in an object say ob
now you can do
ob["name"][0]["somethingelse"][0]["city"]
by reading this mongoDB doc, I see that to access array nested document you need to specify the index of the element instead of using ".".
For example with this object:
I want to access the "birth" property, I will do something like this:
Hope this help.