I have a model with columns:
from: { type: Sequelize.DATE }
to: { type: Sequelize.DATE }
I want to query all records whose either from
OR to
falls in between the date ranges : [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
question from:
https://stackoverflow.com/questions/43115151/sequelize-query-to-find-all-records-that-falls-in-between-date-range 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…