I'm working on an Angular project so I wanted to make a simple Rest API to handle a MySql database, that's why I made one in Node.js but when I tried to delete an item with id = 3, I'm only getting an error that looks like this:
errno: 1064, sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1", sqlState: '42000', index: 0, sql: 'DELETE FROM recipies WHERE id = ?' So I wanted to ask for help. I was thinking that I'm getting this error because these few lines had some logic problems:
Recipe.remove = (id, result) => { sql.query("DELETE FROM recipies WHERE id = ?", id, (err,res) => { if (err) { console.log("error", err); result(null, err); return; } if (res.affectedRows == 0) { // not found recipe with the id result({ kind: "not_found" }, null); return; } console.log("deleted customer with id: ", id); result(null, res); }); };