Search code examples
mysqlsails.jswaterline

How to check value is null or blank in sails js


How can I check value is null or blank in sails using waterline. I can do this with mysql native query but due to some reason I don't want to use it.

I have tried something like below code but it's not working.

var query = {
    Status: [1, 2, 3],
    Date: [null, '']
};
table.count(query).exec(function (err, count) {
    if (err) {
        return res.badRequest(err);
    }
    return res.send(count);
});

Any help would be appreciated.


Solution

  • You have to use or query

    var query = {
        Status : [1, 2, 3],
        or     : [
          { Date : null },
          { Date : '' },
        ],
    };