'Mysql Query does not update the data using Node.js
New to this some sort, I want to know how to make Mysql Update queries. I am trying to initiate an MySQL Update Request, for some reason, it does not update as required. It tells me it has been updated, only for me to check the Database and I see it has not been updated.
My code is looking thus :
app.put('/api/v1/user/updateTripStatus', async function (req, res, next) {
try {
if (!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ') || !req.headers.authorization.split(' ')[1]) {
return res.status(422).json({ message: 'Please Provide Token!' })
}
var id = req.body.id;
var status = req.body.status;
if (!id) {
return res.status(400).send({ error: true, message: 'Please provide ID' });
}
dbConn.query('update becham_deliveries set status =? where id =?', [id, status], function (error, results, fields) {
if (error) throw error;
return res.send({ error: false, data: results[0], message: 'users List.' });
});
} catch (err) {
next(err);
}
})
I check from Mysql Workbench and it still does not have the column of status updated. Please is there something i appear to be doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
