I want to populate the ingredientsList. Is it possible to get the array back with populated ingredients field ? How I can do it, if I want just one object out of ingredientsList with populated ingredient ?
Hope you can help :)
My Schema looks like this:
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,
},
},
],
});
My Ingredient Model looks like this:
export const IngredientSchema = new Schema({
name: {
type: String,
required: 'Enter a name',
},
created_date: {
type: Date,
default: Date.now,
},
amount: {
type: Number,
default: 1,
},
});