Waterline ORM (sails.js) "where or" in query
There was an issue with the development database used by sails (waterline-criteria). The issue was the way strings and integers were handled in sails-disk. In the query criteria below, theScore, was being treated as a string. This has been resolved, so you just need to update sails-disk. You can do this by using npm install sails-disk --force --save
. After that the example below should work fine.
You can try this (Updated):
foo: function(req, res, next) {
var theScore = req.param('id') || 0;
User.find().where({
or: [{
score: {
'>': parseInt(theScore),
},
status: 'user'
},
{ status: 'admin'}]
}).exec(function(err, data) {
if (err) return next(err);
res.json(data);
});
},