How to retrieve array value from mongoDB -


i have data in mongodb

"emp_id" : "1000", "emp_name" : "jim", "department" : [  {      "department_id" : 1,      "contacts" : [      {         "mobile" : 102,         "phone" : "1",      }   ] } 

how retrieve mobile above data in mongo shell?

assuming db.col.findone() finds document you're looking for:

db.col.findone().department.contacts[0].mobile 

should it.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -