I am creating the nested logical operator or and logical operator and, but it gives different results.
const whereClaues = {
DailyMarketId: dailyMarket.id,
TransactionType: TransactionType.Bid,
};
if (bidType == BidType.OPEN) {
whereClaues.BidType = { [Op.in]: [BidType.OPEN, BidType.CLOSE] };
} else {
whereClaues[Op.or] = [
{ BidType: BidType.CLOSE },
{
BidType: BidType.OPEN,
GameId: {
[Op.in]: gameIds,
},
},
];
}
this is the condition in where clause and I am using it in get all query as below:
await models.BidTransaction.findAll({
where: whereClaues,
attributes: [
"UserId",
[Sequelize.fn("sum", Sequelize.col("Coins")), "BidAmount"],
],
group: ["UserId"],
})
console.log(whereclause)
// Error
// {
// DailyMarketId: 193,
// IsActive: true,
// IsWin: true,
// TransactionType: 'Win',
// Open: [ { BidType: 'Close' }, { BidType: 'Open', GameId: [Object] } ]
// }
// Correct
// {
// DailyMarketId: 193,
// IsActive: true,
// IsWin: true,
// TransactionType: 'Win',
// [Symbol(or)]: [ { BidType: 'Close' }, { BidType: 'Open', GameId: [Object] } ]
// }
getting these 2 response. Why ai am getting this 2 different response and from where I get Open field ?