I have a patch endpoint in my REST API where every body parameter is optional. What is the best way of implementing it without checking each parameter manually?
db.none("update tasks set title=$1, description=$2, value=$3 where id=$4",
[req.body.title, req.body.description, parseInt(req.body.value), req.params.id])
.then(function () {
res.status(200)
.json({
status: "success",
message: "Updated task"
});
})
.catch(function (err) {
return next(err);
});