javascript - Querying the corresponding key from the JSON -


i have following json structure in mongo db.

{ "branch": [     {     "section": [         {             "sub": "edc",             "time": "one hour",             "frequency": "3"         },         {             "sub": "bee",             "time": "two hours",             "frequency": "4"         }     ] }, {     "section": [         {             "sub": "ss",             "time": "one hour",             "frequency": "2"         },         {             "sub": "ms",             "time": "two hours",             "frequency": "5"         }     ] }  ] } 

i want perform query such returns values of following key

branch.section.sub

after query want output like

edc bee ss ms 

use projection of find:

db.mycollection.find({}, {"branch.section.sub":1}) 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -