pgpromise 插入返回消息失败,但成功插入到表中

时间:2021-08-01 14:49:46

标签: pg-promise

pg-promise 成功插入一行到表中,但没有显示插入返回记录。 如果我不使用 returning 那么一切都很好。如果使用则出错。

const createEMP = async (req, res, next) => {
try{
   let user = await db.none("insert into emp (name, salary, joindate) 
   values ( ${name}, ${salary}, ${joindate}) returning * ", req.body)

            res.status(200).json({
                user,
                "message": "new user created"
            })
        }
        catch(error) {next(error)}
    }

在邮递员中,它显示了很长的错误页面。它说:<pre>QueryResultError: No return data was expected.<br>.....

1 个答案:

答案 0 :(得分:0)

db.none 更改为 db.one 工作。

相关问题