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

问题描述

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>.....

解决方法

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