Example #1
0
    Section.find({}, function (err, sections) {
      if (err) throw err;

      Product.find({ promo: true }, function (err, products) {
        if (err) throw err;
        res.render('catalog', { sections: sections, products: products });
      });
    });
Example #2
0
function getProducts(req, res){
	Product.find().lean().exec()
	.then(function(products){
		res.send(products);
	})
	.catch(function(err){
		return res.status(500).send({error: t('Could not retrieve the products', req), err: err});
	});
}
Example #3
0
 Section.findOne({ url: req.params.section }, function (err, section) {
   if (err) throw err;
   if (!section) {
     next(new HttpError(404, "Section not found"));
     return;
   }
   Product.find({ sections: section }, function (err, products) {
     if (err) throw err;
     res.render('catalog/item', { section: section, sections: sections, products: products });
   });
 });