【发布时间】:2021-10-07 05:07:42
【问题描述】:
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>.....
【问题讨论】:
-
API for the method 没有清楚地解释该方法期望的结果吗? -
expects no data to be returned。只需阅读文档并遵循它。
标签: pg-promise