【问题标题】:Make nested queries with client [closed]使用客户端进行嵌套查询[关闭]
【发布时间】:2020-11-16 06:04:58
【问题描述】:

我正在做一个查询,根据结果我想再做一个查询。我的代码如下所示:

client.query(Q1, (err, res2) => {
    if (condition(res2)) {
        client.query(Q2), (err, res3) => {
            console.log(res3)
        }
    } else {
        console.log("Condition not fulfilled")
    }
})

两个查询都生效,但从未记录过res3。我做错了什么,我该如何解决?

【问题讨论】:

  • 你在做client.query(Q2); ((…) => {…});。你应该做client.query(Q2, (…) => {…});

标签: node.js postgresql


【解决方案1】:

您在client.query(Q2), (err, res3) => { 中过早关闭了大括号 这应该是:

client.query(Q2, (err, res3) => {

【讨论】:

    猜你喜欢
    • 2014-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-03
    • 2017-03-12
    • 2013-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多