我想按元素的时间戳过滤数据库表。
表有行:ID、URL、时间表。
如何按一定范围内的时间戳过滤数据?就像 SQL 中通常的情况一样...在firstTime 和lastTime 之间
我尝试了这样的事情:
if (first_date && last_date) {
Pages.forge()
.where("Date", '>=' , first_date)
.where("Date", '<=' , last_date)
.fetchAll()
.then(function (pages) {
res.send(persons.toJSON());
}).catch(function (error) {
console.log(error);
res.send('An error occured');
});
model.query({where: {"Date", '>=' , first_date}, orWhere: {"Date", '<=' , last_date}})
.fetch()
.then(function(model) {
// ...
});
您必须使用 where 和 or where 例如: Between 表示两个条件中的任何一个,但在这里您将两个条件都设置为 true 。
我是一名优秀的程序员,十分优秀!