Navigate back to the homepage

Sequelize where in and where not in array example

Infinitbility
Node, Sequelize
July 5th, 2021 · 1 min read
Sequelize where in and where not in array example

Hello Friends,

Welcome To Infinitbility!

This article based on sequelize where in and where not in query, here you will learn to write where in query in sequelize and also how many way to do.

For managing where in and not in types of query sequelize provide operators.

Let start today article Sequelize where in and where not in array example

In this article, you will get examples of query using where in or where not in array.

Sequelize where in array

First Option: You have to just set array in where clause, Sequelize auto understand where in query like below.

1const { Op } = require("sequelize");
2
3Post.findAll({
4 where: {
5 id: [1,2,3,4]
6 }
7});

Second Option: Sequelize also provide Op.in operator to create where in query like below.

1const { Op } = require("sequelize");
2
3Post.findAll({
4 where: {
5 id: {[Op.in]: [1,2,3,4]}
6 }
7});

Sequelize where not in array

Sequelize provide Op.notin operator to make where not in query like below example.

1const { Op } = require("sequelize");
2
3Post.findAll({
4 where: {
5 id: {[Op.notin]: [1,2,3,4]}
6 }
7});

Subscribe Our Newsletter You will get monthly free programming book

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Subscribe Our Newsletter You will get monthly free programming book

Tutorials

React Native

Categories

More articles from Infinitbility

React Native borderColor

React Native borderColor

borderColor in React Native

July 4th, 2021 · 1 min read
React Native borderRadius

React Native borderRadius

borderRadius in React Native

July 4th, 2021 · 1 min read
© 2020–2021 Infinitbility
Disclaimer
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]