Mongoose populate() returns empty array with no errors
I found that during my little research that it will work:
User .findById(req.payload._id) .populate({ path: 'hero.upgrades', model: 'Upgrade' }) .exec(function (err, user) { if (err){ console.log(err); } else { res.status(200).json(user); console.log("success"); } });}
It looks like when user is giving nested object notation i.e. hero.upgrades
into populate
method, Mongoose got problems with detecting referring model.