I have a model with columns:
from: { type: Sequelize.DATE }
to: { type: Sequelize.DATE }
我想查询日期范围为from
或to
的所有记录:[startDate, endDate]
Tried Something Like:
const where = {
$or: [{
from: {
$lte: startDate,
$gte: endDate,
},
to: {
$lte: startDate,
$gte: endDate,
},
}],
};
Something Like:
SELECT * from MyTable WHERE (startDate <= from <= endDate) OR (startDate <= to <= endDate