Verwende populate mit einem dynamischen ref, gesteuert über refPath:
const CommentSchema = mongoose.Schema({ description: String, user_type: String, // Student or Teacher user_id: { type: Schema.Types.ObjectId, refPath: 'user_type' } })
Mongoose liest user_type auf jedem Dokument und löst user_id gegen jenes Modell auf, das dieser Wert benennt.