我希望填充ingredientsList。
有可能获得填充后的ingredients字段的数组吗?
如果我只想要一个填充了ingredient的ingredientsList对象,该怎么做?
希望你能帮忙 :) 我的模式如下:
我的配料模型如下:
希望你能帮忙 :) 我的模式如下:
export const RecipeSchema = new Schema({
name: {
type: String,
required: 'Enter a name',
},
ingredientsList: [
{
ingredient: {
type: Schema.Types.ObjectId,
ref: 'Ingredient',
},
value: {
type: Number,
default: 1,
},
},
],
});
我的配料模型如下:
export const IngredientSchema = new Schema({
name: {
type: String,
required: 'Enter a name',
},
created_date: {
type: Date,
default: Date.now,
},
amount: {
type: Number,
default: 1,
},
});