{
orders: {
userID: { type: Schema.Types.ObjectId, ref: 'User' },
order: [
{
productID: { type: Schema.Types.ObjectId, ref: 'Inventory' },
quantity: { type: Number },
vendorCoupon: { type: String },
},
],
}
}
I have an orderSchema something like this. I can populate userID like that :
Order.find({ userID: req.body.userID }).populate('userID')
... some other code snippet ...
But how should I populate the productID inside this order array ? I have to map all the productID's in the array. How can I implement it ?