I have a very big problem when im trying to access objects in array in mongoDB.
First I'm finding where id key has a value of "mens" in my database collection "categories":
mongodb.db().collection("categories").find({id: "mens"}).toArray(function(err, data) {
console.log(data);
}
When i try to output the result in the console, it shows me this :
[ { _id: 5172d1daffdd81f3234d5f88,
categories: [ [Object], [Object] ],
id: 'mens',
name: 'Mens',
page_description: 'Men\'s range. Hard-wearing boots, jackets and clothing for unbeatable comfort day in, day out.
headed.',
page_title: 'Men\'s Footwear, Outerwear, Clothing & Accessories',
parent_category_id: 'root',
c_showInMenu: true } ]
But when I try to get for example name or page_title with this :
mongodb.db().collection("categories").find({id: "mens"}).toArray(function(err, data) {
console.log(data.page_title);
}
It returns UNDEFINED ! ! !