以下代码不起作用:
model.find({
where: {
id: 1,
publishedAt: Sequelize.DATE
}
})
我试图找到id = 1的模型,但前提是它的publishedAt值是一个日期。
答案 0 :(得分:1)
好的,我最好的选择应该是在查询后过滤日期值。
//Finds out if the given value is a valid date. You can add some more specific checks.
var isDate = function(date) {
return ( (new Date(date) !== "Invalid Date" && !isNaN(new Date(date)) ));
}
model.find({
where: {
id: 1,
publishedAt: {
$ne: null
}
}
}).
filter(function(record) {
return isDate(record.publishedAt);
})