gpt4 book ai didi

node.js - 水线 (Sails.js)。 'updatedAt' 大于给定值的行

转载 作者:搜寻专家 更新时间:2023-10-31 23:02:14 25 4
gpt4 key购买 nike

我想从模型中获取 行。在给定日期之后创建的行。查询应该很简单:

其中 updatedAt>= givenDate

但它不起作用:(

我的代码:

        // Date from client
var lastDate = req.param("date");

// Parse date with moment? I have tried with and without this.
lastDate = moment(lastDate).format('YYYY-MM-DD hh:mm:ss');

var query = Message.find().where({
updatedAt: {
'>=': lastDate
}
});

query.exec(function(err, messages) {
// I get ALL the messages, :(
res.send(messages);
});

提前致谢。

最佳答案

已解决。

我创建了一个 Date 实例并将其传递给 where 子句:

// Date from client: Date in MS (new Date().getTime())
var lastDate = req.param("date");

// Create date
lastDate = new Date(lastDate);


var query = Message.find().where({
updatedAt: {
'>=': lastDate
}
});

query.exec(function(err, messages) {
// I get ALL the messages, :(
res.send(messages);
});

关于node.js - 水线 (Sails.js)。 'updatedAt' 大于给定值的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24336185/

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