Reputation: 16131
i'm using Sequelize 5.18.0 and sequelize-typscript. I need to do a where clause with and
and a .fn
to find rows where a DateTime column are from a given day.
What is the correct syntax to do this?
return STTermin.schema(ctx.tenant).findAll({
where: {
[Op.or]: [
{
[Op.and]: {
Sequelize.where(Sequelize.fn('DATE', Sequelize.col('von')), '2019-10-17'),
bis: {
[Op.is]: null
}
}
},
Which gives me the following error:
Upvotes: 0
Views: 1198
Reputation: 1968
Both Op.and
and Op.or
require an array of arguments. So:
[Op.or] : [
[Op.and]: [
Sequelize.where(Sequelize.fn('DATE', Sequelize.col('von')), '2019-10-17'),
{bis: {[Op.is]: null}}
],
{ otherColumn : 123455 } /* some other condition */
]
FWIW, I find the Operator Aliases to improve code clarity...
Upvotes: 1