How to compare two columns not having same value using sequelize orm

Viewed 563

I have two fields in my table dispatchCount & qty.

I want to findOne tuple where dispatchCount is not equal to qty

I want to do something similar to this (Mysql Select Rows Where two columns do not have the same value) but using sequelize ORM.

I don't want to write the raw query myself bcz there are a lot of aliases & things like that. So how can I do the following using sequelize

SELECT *
FROM my_table
WHERE column_a != column_b
1 Answers

The following is the solution without writing raw query to do so :-

let en = Entity.findOne({
    where: {
        dispatchCount : {
            [Op.ne]: sequelize.col("qty");
        }
    }
})
Related