我有一个具有列的模型:
from: { type: Sequelize.DATE }
to: { type: Sequelize.DATE }
我想查询所有记录,其from
或者to
落在日期范围[开始日期, 结束日期]
之间。
我尝试了一些类似的方法:
const where = {
$or: [{
from: {
$lte: startDate,
$gte: endDate,
},
to: {
$lte: startDate,
$gte: endDate,
},
}],
};
类似这样的:
SELECT * from MyTable WHERE (startDate <= from <= endDate) OR (startDate <= to <= endDate
from: { $gte: startDate, $lte:endDate }
- frlinw