从 node-postgres 中的 SELECT 查询返回结果时遇到问题。现在行在代码块的末尾是空的。此选择仅从 POSTGRESQL 中的序列返回下一个值。我知道您无法从回调中检索结果,但是这里是否有人使用过 node-postgres(或任何其他数据库模块到节点)可能知道修复?
client.connect();
var query = client.query("SELECT nextval(\'idgenerator\');");
var rows = [];
query.on('row', function(row, res) {
rows.push(row);
});
query.on('end', function(result) {
console.log(result.rowCount + ' rows were received');
});
//client.end();
console.log(rows);