I'm new to sails.js. It seems that there is no way for sails.js to make a SQL query for select some fields/columns of a table. The queries seem all "select * ".
I just found a way to make this happen. I am using the 2nd parameter of Model.find
Model.find({field: 'value'}, {fields: ['id', 'name']})
If you set fields to false it simulates a SELECT *
Model.find({field: 'value'}, {fields: false})
A complete example:
Model.find({field: 'value'}, {fields: ['id', 'name']})
.paginate({page: 1}, {limit: 10)
.exec(function(err, results) {
if(err) {
res.badRequest('reason');
}
res.jsonx(results);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With