The following code works fine as long as the entry is not blank. However, sometimes a user may want to delete a text entry, and therefore the cell should be replaced with an empty value (or null).
db.one(`UPDATE objectives
SET details = $1
WHERE id = $2 RETURNING project_id`, [details, id])
When querying for data with pg-promise, use:
.one if you are expecting one row (as an object) .any if you are expecting an arrow of row objects .none if you are expecting nothing returned .oneOrNone if you are expecting one row or no rows returned.
the solution was to use db.oneOrNone instead of db.one
More info can be found: https://github.com/vitaly-t/pg-promise#methods