How to populate nested object ref

24 views
Skip to first unread message

yogesh bansal

unread,
Aug 18, 2017, 2:29:04 AM8/18/17
to Mongoose Node.JS ODM
Hi,

I have nested object ref and i want to populate it. My schema is something like this

var product = new Schema({
product: {type:Schema.Types.ObjectId, ref:'product'},
count: Number
});

var orderSchema = new Schema({
orderItems :[product],
});
var customerSchema = new Schema({
orders: [{type: Schema.Types.ObjectId, ref: 'orders'}],
});

I want to all the orders of a customer and all the items in each order.
Please guide me how can i populate it

Thanks
Reply all
Reply to author
Forward
0 new messages