【发布时间】:2021-04-15 17:05:56
【问题描述】:
我在将 pool.query 的结果添加到变量时遇到问题(使用 pool.query 我只选择一个值,id 值,我需要插入到其他表中)。到目前为止,我有这个,但 console.log 给了我
承诺{ }
router.get("/restaurants/add",checkNotAuthenticated, async (req, res) => {
var x = pool.query(`select delivery.id from delivery order by id desc limit 1`);
console.log(x);
/*pool.query(
`INSERT INTO new_table (newId)
VALUES ($1)`,
[x]);*/
res.redirect("/restaurants/dashboard")
});
任何帮助都会很有价值。
【问题讨论】:
-
看起来你缺少 await 所以承诺没有解决。
标签: sql node.js postgresql express web-applications