I have a data like follows
"student" : [
ObjectId("58500ea5ef914125073b040f"),
ObjectId("58500ea5ef914125073b042e")
],
my model,
student: [{type: Schema.ObjectId,ref: 'Student'}],
I want to populate student in these array,
Classroom.findById(id).populate('student.student'){}
It is not working,can anyone please suggest help.Thanks.
From what i can see in your data,
student
is thearray
of students, so you need to just writestudent
in thepopulate
query.this should work for you :