r.db('dbname').table('urls').filter(function(url) {
return url("expires_at").date().eq(r.now().date())
.and(url("expires_at").hours().eq(r.now().hours().sub(1)))
});我试图使用thinky为node.js编写等价的查询。
发布于 2015-11-15 14:48:35
我从未使用过Thinky,但根据docs,您应该创建模型并对其进行查询。
1)建立模型。我不知道你在重新思考什么文件。但就像这样:
var thinky = require('thinky')();
var type = thinky.type;
// Create a model
var Urls = thinky.createModel("urls", {
id: String,
expires_at: Date
// another fields if needed
}); 2)查询:
不知道Thinky中过滤器的实际语法,但如下所示:
Urls.filter(function(url) {
return url("expires_at").date().eq(r.now().date())
.and(url("expires_at").hours().eq(r.now().hours().sub(1)))
}).then(function(result) {
// result is an array of instances of `Urls `
});https://stackoverflow.com/questions/33716983
复制相似问题