Quisiera saber si es posible bajar la cantidad sin tocar la base de datos porque aquí me gustaría que la variable cantidad disminuya pero sin actualizar la base de datos. De hecho, la variable permanece constante y no llega a cero si no actualizo en la base de datos con cada clic del botón.
Aquí está mi código:
db.query("SELECT * FROM articles WHERE id_article = ?", [[req.articleId]], function (err, result) { if (err) throw err; let quantity = result[0].quantite - 1; if (result[0].quantite < 1) { } else { db.query("UPDATE articles SET quantite = ? WHERE id_article = ?", [quantity, req.articleId], function (err, result) { // I want to know if it's possible to make that without directly update the database... if (err) throw err; }) let token = req.headers['x-access-token'] || req.headers['authorization'] || req.cookies.token; db.query("SELECT quantite FROM panier_item WHERE id_article = ? AND id_user = ?", [req.articleId, parseJwt(token).userId], function (err, result) { if (err) throw err; console.log(result[0]) if (result[0] === undefined) { db.query("INSERT INTO panier_item(id_article,id_user,quantite) VALUES (?)", [[req.articleId, parseJwt(token).userId, 1]], function (err, result) { if (err) throw err; }) } else { db.query("UPDATE panier_item SET quantite = ? WHERE id_article = ? AND id_user = ?", [result[0].quantite + 1, req.articleId, parseJwt(token).userId], function (err, result) { if (err) throw err; }) } }) }Gracias a todos,