Sequelize Query Where not equal and Other Conditions

Muhammad Fazeel

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?

Eggon

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 }... }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related