Node.js 如何在mongoose中填充多个外键

Node.js 如何在mongoose中填充多个外键,node.js,mongodb,mongoose,populate,Node.js,Mongodb,Mongoose,Populate,假设我已经为userId中的id设置了对象引用和对象引用: { "__v" : 0, "_id" : ObjectId("530d8aa855df0c2d269a5a58"), "active" : false, "address" : "some ip address", "createDate" : ISODate("2014-02-26T06:33:12.367Z"), "displayName" : "coolguy55", "fu

假设我已经为userId中的id设置了对象引用和对象引用:

{
    "__v" : 0,
    "_id" : ObjectId("530d8aa855df0c2d269a5a58"),
    "active" : false,
    "address" : "some ip address",
    "createDate" : ISODate("2014-02-26T06:33:12.367Z"),
    "displayName" : "coolguy55",
    "fullName" : "super cool guy 55",
    "userId" : [ 
        ObjectId("an ID"), 
        ObjectId("an ID")
    ]
}

我想知道是否可以在一个populate语句中填充这两个ID?

只要您的模式将
userId
定义为对适当模型的ObjectId引用数组,调用
populate('userId')
将填充整个数组:

MyModel.find().populate('userId').exec(...);