如何根据 updatedAt
列进行搜索。我希望所有记录在 date
之后按升序排列。
var date = "2016-06-18 05:18:27"
Person.findAll({
where: {
updatedAt: `> date` //greater than this date?
},
orderBy: '`group` DESC'
}).then((people) => {
})
最佳答案
你应该使用 range operator $gt
指定一个大于给定 Date
的 updatedAt
。至order the results传递一个元素数组,在这种情况下,它应该是一个数组,其中列作为第一个元素,方向作为第二个元素,例如 [['column', 'DESC']]
.
var date = '2016-06-18 05:18:27';
var myDate = new Date(date);
Person.findAll({
where: {
updatedAt: {
$gt: myDate,
},
},
orderBy: [['group', 'DESC']],
}).then((people) => {
// results are here
});
关于mysql - Sequelize : Get records after updatedAt date,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41195284/