0

I'm using mysql, when I try to run this query:

Order.findAll({
   where: {
    end_date: {
     $ne: null,
    }, 
   },
});

The where clause it generates looks like this:

where: "`Order`.`end_date` = '2020-03-11 03:00:00'

I tried using $nin and $not, I also tried using a raw query, and I still get the same result.

I see there was a bug with sequelize and mysql a few versions behind, but it seems like it was fixed on 5.19.5, and I'm using v 5.21.5.

Mysql version is 5.7.29

Can anyone help me with this?

Edit: Found a solution somewhere else, all I had to do was use [Op.not]. In case anyone needs this as well.

1 Answers1

2

That won't work with sequelize v5. Here is the way to go.

const Op = require('sequelize').Op

Order.findAll({
   where: {
    end_date: {
     [Op.ne]: null,
    }, 
   },
});

You can read more about using operators here. Deprecation warning here.

sujeet
  • 3,480
  • 3
  • 28
  • 60