I haven't had a chance to test this out yet, but would look something like this if you were patching just a single field:
app.patch("/api/v1/issues/:id", (req, res) => {
const { id } = req.params;
const {key, value} = req.body;
pool.query(
"UPDATE issues, SET $1 = $2 WHERE id = $3",
[key, value, id],
(error, results) => {
if (error) {
throw error;
}
res.sendStatus(200);
}
);
});
Pretty much just like PUT except you're also passing the field name in the request body along with the value. If you wanted to PATCH multiple fields at the same time then you could pass arrays of keys and values and just loop through them to template string a single UPDATE statement.