Sometimes, we want to fix error when using “where” and “in” on a subarray with Node.js Sequelize.
In this article, we’ll look at how to fix error when using “where” and “in” on a subarray with Node.js Sequelize.
How to fix error when using “where” and “in” on a subarray with Node.js Sequelize?
To fix error when using “where” and “in” on a subarray with Node.js Sequelize, we can set the where
property to an object with the properties being the fields we’re filtering by.
And we set the properties to arrays to search for the entries with any of the values.
For instance, we write
await Tag.findAll({
where: {
id: [1, 2, 3, 4]
}
})
to call findAll
with where.id
set to [1, 2, 3, 4]
to find the Tag
items with id
set to 1, 2, 3, or 4.
Conclusion
To fix error when using “where” and “in” on a subarray with Node.js Sequelize, we can set the where
property to an object with the properties being the fields we’re filtering by.
And we set the properties to arrays to search for the entries with any of the values.