Hello Friends,
Welcome To Infinitbility!
This article based on where or query in node sequelize, here you will get example of where or query.
Sequelize provide operator functionality to manage this types of query.
For using operator you have to import op
from sequelize like below.
1const { Op } = require("sequelize");
For using or condition we have to Op.or
in where condition like below example.
1const { Op } = require("sequelize");2Post.findAll({3 where: {4 [Op.or]: [5 { authorId: 12 },6 { authorId: 13 }7 ]8 }9});
Where or query output
1// SELECT * FROM post WHERE authorId = 12 OR authorId = 13;
Thanks for reading…
Follow me on Twitter
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.