Multiple populates - mongoosejs

后端 未结 8 1743
傲寒
傲寒 2020-12-04 17:33

Just a simple query, for example with a double ref in the model.

Schema / Model

var OrderSchema = new Schema({

    user: {
                 


        
8条回答
  •  既然无缘
    2020-12-04 18:06

    You're already using the correct syntax of:

    OrderModel.find()
        .populate('user')
        .populate('meal')
        .exec(function (err, results) {
             // callback
        });
    

    Perhaps the meal ObjectId from the order isn't in the Meals collection?

提交回复
热议问题