This is my MongoDB schema:
var partnerSchema = new mongoose.Schema({
name: String,
products: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Product'
}]
});
var productSchema = new mongoose.Schema({
name: String,
campaign: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Campaign'
}
]
});
var campaignSchema = new mongoose.Schema({
name: String,
});
module.exports = {
Partner: mongoose.model('Partner', partnerSchema),
Product: mongoose.model('Product', productSchema),
Campaign: mongoose.model('Campaign', campaignSchema)
}
And I'd like to send all documents (partner
>product
>campaign
) to my View as a one object.
I know how to send partner
with product
ref. For example:
var campSchema = require('../model/camp-schema');
router.get('/partner-list', function (req, res) {
campSchema.Partner.find({}, function (err, partnerList) {
if (err) throw err;
res.json({ partnerList: partnerList });
}).populate('products');
});
And I can easily iterate at view in this way:
li(ng-repeat="product in partner.products")
a(href="#") {{ product.name }}
And here is the question. How can I pass ONE object as a document with partner
, product
and campaign
. Because at the moment I have only partner
and product
in that object.