我正在使用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上返回以下内容:
select CURRENT_TIMESTAMP;
mikaelle=# select CURRENT_TIMESTAMP; now ------------------------------- 2018-12-10 14:48:01.472945+02 (1 row)
1 回答
这应该做:
也许你还应该告诉你想要的结果是什么 .
编辑:编辑查询以实际从响应中获取行和列,因为
select CURRENT_TIMESTAMP;
在postgres上返回以下内容: