我正在使用 Knex 并使用原始查询来获取 Postgres 数据库的当前时间戳。我正在使用
knex.raw('select now()').then(function(resp)
{
console.log(resp)
})
但我无法得到想要的结果。请告诉我我能做什么的解决方案。
这应该做:
knex.select(knex.fn.now()).then(res => console.log(res[0].now));
也许你也应该告诉你你想要的结果是什么。
编辑:编辑查询以实际从响应中获取行和列,因为
select CURRENT_TIMESTAMP;
在 postgres 上返回以下内容:
mikaelle=# select CURRENT_TIMESTAMP;
now
-------------------------------
2018-12-10 14:48:01.472945+02
(1 row)