gpt4 book ai didi

node.js - Nodejs 书架。如何使用BETWEEN过滤器

转载 作者:太空宇宙 更新时间:2023-11-03 21:56:14 27 4
gpt4 key购买 nike

我想按元素的时间戳过滤数据库表。

表有行: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 。

关于node.js - Nodejs 书架。如何使用BETWEEN过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39964724/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com