`const facultySchema = new Schema({
title: {
type: String,
required: true
},
groups: [{
type: Schema.Types.ObjectId,
ref: 'Group'
}]
})
export default model('Faculty', facultySchema)`
`const groupSchema = new Schema({
title: {
type: String,
required: true
},
students: [{
type: Schema.Types.ObjectId,
ref: 'Student',
}],
journals: [{
type: Schema.Types.ObjectId,
ref: 'Journal'
}]
})
export default model('Group', groupSchema)`
here is my service whe i have error MissingSchemaError: Schema hasn't been registered for model "Group". This error happend when i try to populate groups
`class FacultyService {
getFaculties = async () => {
const faculties = await Faculty.find().populate('groups')
if(!faculties) return null
return faculties
}
}
export const facultyService = new FacultyService()`
when i add code const gr = await Group.find() to my getFaculties fucction error disappear.