//=> student.service.ts
const getAllStudentsFromBD = async () => {
const result = await Student.find()
.populate('admissionSemester')
.populate({
path: 'academicDepartment',
populate: {
path: 'academicFaculty',
},
});
return result;
};
here i got the admissionSemester id then I input semester id inside populate, then I get full details of this admissionSemester id.
//=>src/app/modules/academicDepartment/academicDepartment.model.ts
const academicDepartmentSchema = new Schema<TAcademicDepartment>(
{
name: {
type: String,
required: true,
unique: true,
},
academicFaculty: {
type: Schema.Types.ObjectId,
ref: 'AcademicFaculty',
},
},
{
timestamps: true,
},
);
ref: 'AcademicFaculty',
.populate('modelname')
Top comments (0)