Estoy tratando de agregar una condición condicional a mi consulta Sequelize para poder filtrar como se muestra a continuación, pero actualmente no funciona, porque sobrescribe $and .
¿Cómo lo hago correctamente?
const params = { where: { $or: sequelize.literal( `exists (select 1 from "FootballGamePlayers" fp where fp.game_id = "FootballGame".id and fp.player_id = ${req.user_id}) OR exists (select 1 from "FootballGameInvites" gi where gi.game_id = "FootballGame".id and gi.user_id = ${req.user_id}) `) } if (req.query.isActive === 'true') { params.where = { ...params.where, $and: sequelize.literal('end_date > NOW()') } } else if (req.query.isActive === 'false') { params.where = { ...params.where, $and: sequelize.literal('end_date < NOW()') } } await FootballGames.findAndCountAll(params)