I\'ve got a schema that looks a bit like:
var conversationSchema = new Schema({
created: { type: Date, default: Date.now },
updated: { type: Date, de
For anyone else coming across this question.. the OP's code has an error in the schema definition.. it should be:
var conversationSchema = new Schema({
created: { type: Date, default: Date.now },
updated: { type: Date, default: Date.now },
recipients: [{ type: Schema.ObjectId, ref: 'User' }],
messages: [ conversationMessageSchema ]
});
mongoose.model('Conversation', conversationSchema);
Use the name of the schema path instead of the collection name:
Conversation.findOne({ _id: myConversationId})
.populate('recipients') // <==
.exec(function(err, conversation){
//do stuff
});