mysqlnode.jsormsequelize.js

Sequelize select * where attribute is NOT x


looking at the docs you can use model.findAll({where: {attribute: x}}). However, I want to select all attributes that are simply NOT x. I was looking into a regular expression here but that seemed like not an optimal solution.

What is the best way to do this?


Solution

  • Try this

    model.findAll({where: {attribute: { $not: 'x'}}})
    

    Sequelize actually provides many operators for you to get your filter data.

    You can refer to the link here