【发布时间】:2012-10-04 20:55:40
【问题描述】:
我正在使用 mongoose 查询我的 mongodb,但我不明白为什么返回的子文档只是 Object 类型,而不是 JSON。
使用
hero.find({} ,{'deck' : {$elemMatch:{name:'Guard Tower'}}}, function(err, tower) {
console.log(tower);
}
返回
[ { _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] } ] } ]
像动画,大小,弹丸,升级,是对象的子文档,我需要嵌套的信息,我怎样才能得到信息?不进行其他查询?
【问题讨论】:
标签: javascript mongodb mongoose