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
Post a Comment