I have this code
exports.index = function (req, res) {
res.render('product/index.jade', {
products: db.products.find().toArray(function (err, prods) {
if (!err)
return prods;
return [];
})
});
};
What I'm trying to do here is pass the query result to a jade view which expects a parameter named "products". I ve tried a lot of combinations but neither of them works (right now i'm getting "cannot read proprty lenght...."). I know it must be a rookie mistake, but i cannot figure it out, any help will be apreciated!
PS: I'm using express and mongodb. And yes, the products collection does contain products.