Whenever I populate a collection in Sails.js, the values are populated inside modelName.associations.collectionName.value. The value of modelName.collectionName is always undefined even though when I represent the object as JSON everything is shown perfectly.
Taking the example of a Many-to-Many relationship given in the documentation (http://sailsjs.org/#/documentation/concepts/ORM/Associations/ManytoMany.html), if I do the following query:
User.findOne(1)
.populate('pets')
.exec(function(err, owner) {...});
I would get the pets collection in owner.associations.pets.value, but owner.pets is undefined.
Any ideas what is going on here?
EDIT:
I have replicated the exact same example given in the documentation (the same Pet.js, User.js and bootstrap.js) and I have overridden the findOne blueprint of User.js in this way:
findOne: function (req, res) {
User.findOne(req.params.id)
.populate('pets')
.exec(function(err, owner) {
if (err) return res.send(err, 500);
return res.json(owner);
});
}
As I expected, the JSON response is alright, but if I set a breakpoint inside the exec(..) function, owner.pets is undefined. The data is only in owner.associations.pets.value.
Could it be my version of Sails.js? It's 0.10.0-rc11.