custloc.updateById = (id, cust, result) => {
sql.query(
"UPDATE fines SET st_name = ? , address = ? , phone = ? , location = ? WHERE id = ?",
[cust.st_name,cust.address,cust.phone,cust.location,id],
(err, res) => {
if (err) {
console.log("error: ", err);
result(null, err);
return;
}
if (res.affectedRows == 0) {
// not found custloc with the id
result({ kind: "not_found" }, null);
return;
}
console.log("updated cust: ", { id: id, ...cust });
result(null, { id: id, ...cust });
}
);
};