I am making a search in a database which have a table productDetails.
I want a query something like this in sequelize,
SELECT * FROM productDetails
WHERE title
LIKE '%search1%' OR title
LIKE '%search2%'
currently using
const pd= await ProductDetail.findAll({
where: {
[Op.or]: {
title: { [Op.like]: `%search1%` },
title: { [Op.like]: `%search2%` },
},
},
CodePudding user response:
Just indicate all conditions as an array as a value of Op.or
like this:
where: {
[Op.or]: [
{ title: { [Op.like]: `%search1%` } },
{ title: { [Op.like]: `%search2%` } },
],
},
See examples here