I am querying my mongodb using mongoose, but i don’t understand why the returned sub docs are just of type Object, instead of JSON.
Using
hero.find({} ,{'deck' : {$elemMatch:{name:'Guard Tower'}}}, function(err, tower) {
console.log(tower);
}
returns
[ { _id: 507ac406ba6ecb1316000001,
deck:
[ { name: 'Guard Tower',
description: 'This tower shoots stuff.',
cost: 13,
sellValue: 7,
radius: 180,
speed: 40,
dmg_min: 0,
dmg_max: 0,
actual_height: 40,
sprite: 'guardtower_red.png',
anim: [Object],
size: [Object],
projectile: [Object],
upgrade: [Object] } ] } ]
Subdocument like anim, size, projectile, upgrade, is Object, i need the information nested, how can i get the information? Without making another query?
The all docs and subdocs are objects in JavaScript. It’s just that
console.loguses the default depth of 2 when callingutil.inspectto format your document for output. You can output all levels of the document by callingutil.inspectyourself: