Javascript Express Postgres未处理承诺拒绝警告

Javascript Express Postgres未处理承诺拒绝警告,javascript,node.js,postgresql,express,Javascript,Node.js,Postgresql,Express,我正在用express和postgres学习Node JS,当我制作CRUD应用程序时,我在执行INSERT INTO语句时遇到了这样的错误 (node:4998) UnhandledPromiseRejectionWarning: TypeError: Invalid Query Result Mask specified. at Database.$query (/home/aabishkar/Documents/meanstack/node_modules/pg-promise/lib/q

我正在用express和postgres学习Node JS,当我制作CRUD应用程序时,我在执行INSERT INTO语句时遇到了这样的错误

(node:4998) UnhandledPromiseRejectionWarning: TypeError: Invalid Query Result Mask specified.
at Database.$query (/home/aabishkar/Documents/meanstack/node_modules/pg-promise/lib/query.js:121:25)
at Database.<anonymous> (/home/aabishkar/Documents/meanstack/node_modules/pg-promise/lib/query.js:259:23)
at config.$npm.connect.pool.then.db (/home/aabishkar/Documents/meanstack/node_modules/pg-promise/lib/database.js:326:42)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) (node:4998) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) (node:4998) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
数据库已连接。以下代码也可以很好地用于参考。当我尝试动态插入值时会出现错误

//this codes works finely
exports.addlist = function(req, res) {
  qry = "INSERT INTO students (name, gender, dob) VALUES ('sdasda', 'male', '12-12-1999')";
  db.query(qry, function (err, result) {
    if (err) throw err;
    console.log("Number of records inserted: " + result.affectedRows);
  });
  res.redirect('/');
}
谢谢。

返回一个
承诺
,它不需要回调。您正在错误地使用库。如果值是第二个参数,那么第三个参数不应该是回调,而应该是

您应该在以下情况下使用它:

db.query(...)
 .then(r => console.log(r))
 .catch(e => console.log(e))

查看此

是否确定
占位符对
pg promise
有效?看见
db.query(...)
 .then(r => console.log(r))
 .catch(e => console.log(e))