Mongoose - using Populate on an array of ObjectId

后端 未结 2 686
旧时难觅i
旧时难觅i 2020-12-05 02:25

I\'ve got a schema that looks a bit like:

var conversationSchema = new Schema({
    created: { type: Date, default: Date.now },
    updated: { type: Date, de         


        
2条回答
  •  无人及你
    2020-12-05 03:02

    Use the name of the schema path instead of the collection name:

    Conversation.findOne({ _id: myConversationId})
    .populate('recipients') // <==
    .exec(function(err, conversation){
        //do stuff
    });
    

提交回复
热议问题