Пожалуйста, укажите имя коллекции модели сначала для обеих схем, а затем в ref поместите имя коллекции AssessationSchema,
Другое, вы не можете ссылаться на поле, вы можете только ссылаться на схему (сделать ссылку на поле можно)в агрегации mongodb с $ project)
let itemSchema = mongoose.Schema({
description: String,
evaluations: [
{
evaluation: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Eval',
required: true,
index: true
},
selection: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Eval', // How do i reference to 'selection' field here?
required: true,
index: true
}
}
]
});
mongoose.model("Item", itemSchema);
let evaluationSchema = mongoose.Schema({
name: {type: String, required: true},
selections: [
{
name: {type: String, required: true },
value: { type: Number, min: 0, max: 15 },
}
],
});
mongoose.model("Eval", evaluationSchema);