Запрос какой-то странный)Ребус для наркомана)
function userWin(val) {
return new Promise(function (resolve, reject) {
const par = [val.gold,val.xp,val.user];
const win = `UPDATE user SET monets = ${par[0]},exp = ${par[1]} WHERE uid = ${par[2]}`;
connection.query(win, (err, results) => {
if (err) reject(err);
resolve(results);
});
connection.end();
}).then(r => {
console.log(r)
})
}
А правильно будет так:
function userWin(val) {
return new Promise(function (resolve, reject) {
const par = [val.gold,val.xp,val.user];
let monets = par[0],
exp = par[1];
const win = `UPDATE user SET ? WHERE uid = ${par[2]}`;
connection.query(win, {monets,exp}, (err, results) => {
if (err) reject(err);
resolve(results);
});
connection.end();
}).then(r => {
console.log(r)
})
}