RethinkDB - 按时间戳检索数据:不是 TIME 伪类型?

RethinkDB - retrieving data by timestamp: Not a TIME pseudotype?

我使用 JavaScript 的日期创建时间戳:

let timestamp = Date.now()

所以我会这样设置时间戳:

1574651336667
1574651408395
1574651361751

当我想检索在 25 日插入的行时:

r.table("users").filter(
    r.row("timestamp").day().eq(25)
).run(conn, callback)

但是我得到这个错误:

Not a TIME pseudotype: `1574651336667` in:\nr.table(\"users\").filter(function(var_0) {

这是什么意思?

如何使用时间戳正确检索数据?

r.epochTime 函数可以将这些时间戳转换为重新考虑的日期时间格式:

r.table("users").filter(function(f){
   return r.epochTime(f("timestamp").div(1000)).day().eq(25)
})

您也可以考虑在插入数据时使用r.now()。这样你就不用再转换了。