samedi 28 février 2015

How can I filter populated values in sails.js?

I have model User. To simplify my issue it has not attributes (except id that is produced by sails engine):



module.exports = {

}


I have also model UserPost:



module.exports = {
attributes: {
user: {
required: true,
model: 'user'
}
}
}


I want to find posts of user with id equal to 42. I have that records in database, both user with id 42, and its posts.


This doesn't work:



UserPost.find().populate('user', {
id: 42
}).exec(function(err, posts) {
res.json(posts);
});


How can I do that?


Aucun commentaire:

Enregistrer un commentaire