waterline - Sails.js populate with where -
i need select users dogs (pets type
equal 'dog')
var user = waterline.collection.extend({ identity: 'user', attributes: { firstname: 'string', lastname: 'string', pets: { collection: 'pet', via: 'owner' } } }); var pet = waterline.collection.extend({ identity: 'pet', attributes: { type: 'string', name: 'string', owner: { model: 'user' } } });
i didn't find examples, tried this
user.find().populate('pets', {type: 'dog'}).exec(err, users) ...
and this
user.find().where({'pets.type': 'dog'}).populate('pets').exec(err, users) ...
but not work
would greate if result users array has no pets records
did try this?
user.find().populate('pets', { where: { type: 'dog' } }).exec(err, users)...
Comments
Post a Comment