Reputation: 568
I want to make the query id not equal in Sequelize.
Here is my current sequelize query:
return db.Area.findAll({
where: { id: { $ne: Id },
slug: conditions.slug }
})
The resulting SQL Query:
*SELECT `id`, `title`, `name`, `titleL1`, `nameL1`, `level`, `slug`, `createdAt`, `updatedAt`, `ParentId` FROM `Areas` AS `Area`
WHERE `Area`.`id` = '[object Object]' AND `Area`.`slug` = 'Nakyal-1';*
This part is not correct:
WHERE `Area`.`id` = '[object Object]'
What am I doing wrong?
Upvotes: 7
Views: 10690
Reputation: 2356
I don't know if it is your case, but I had problems using shortcut '$' operators from sequelize. You might try this approach:
const Op = require('sequelize').Op;
***
where: { id: { [Op.ne]: Id }... }
Upvotes: 10