pg-promise successfully inserted an row into table, but not showing insert return record.
If i not use returning
then all is fine. if using then error occurs.
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)}
}
In postman, it shows a very long page of error. It says: <pre>QueryResultError: No return data was expected.<br>.....