mongoose/mongodb.populate-嵌套文档数组&;质疑

mongoose/mongodb.populate-嵌套文档数组&;质疑,mongodb,mongoose,Mongodb,Mongoose,我正在尝试执行mongodb.populate查询我的Users架构,以检索用户正在参与的事件的文档列表。我有两个Mongodb模式 我尝试了很多方法,包括: Users.findById(req.params.id) .populate('ticketsBought') // will return all event documents referenced in this ticketsBought Array .exec(function (err, results) {

我正在尝试执行
mongodb
.populate
查询我的
Users架构
,以检索用户正在参与的
事件的
文档列表。我有两个
Mongodb
模式

我尝试了很多方法,包括:

Users.findById(req.params.id) 
  .populate('ticketsBought') // will return all event documents referenced in this ticketsBought Array 
  .exec(function (err, results) { 
      if (err) throw err; res.json(results); 
   });
以及我自己的版本,我已经删除了:

var schema = new Schema({
    name: String
  , em: [{ arr: [{ person: { type: Schema.ObjectId, ref: 'Person'}}] }]
});
A.findById(id).populate('em.arr.person').exec(function (err, doc) {
  console.log(doc.em[0].arr[0].person instanceof mongoose.Document) // true
})
用户有:

ticketsBought: {
    type: [mongoose.Schema.Types.ObjectId],
    ref: 'Events',
    default: []
},
attending: {        
    type: [mongoose.Schema.Types.ObjectId],
    ref: 'Users'
},
事件有:

ticketsBought: {
    type: [mongoose.Schema.Types.ObjectId],
    ref: 'Events',
    default: []
},
attending: {        
    type: [mongoose.Schema.Types.ObjectId],
    ref: 'Users'
},

我在这里尝试了
populate
的每个示例,得到的只是一个空数组或一个mongo
ObjectId的数组

请向我们展示您迄今为止所做的尝试。所有相关内容。在mongoose wiki中填充:-我想可能我没有在代码中正确使用Ref和名称。我只想要这样一个简单的东西:Users.findById(req.params.id).populate('ticketsbound')//将返回此ticketsbound数组中引用的所有事件文档。exec(函数(err,results){if(err)throw err;res.json(results);});我只想让你编辑这个问题,并添加你在代码中所写的内容。我无法浏览git回购中的所有方法。很抱歉,我删除了我尝试过的大部分不起作用的内容,我将在下次发布。我编辑了它,并加入了我尝试过的两个东西。