【发布时间】:2018-01-31 21:11:27
【问题描述】:
我的代码应该检索用户 ID 的“DropsRemaining”(它成功),然后从它检索的数字中检索 -1。检索数据时,它返回此字符串“[RowDataPacket { DropsRemaining: 5 } }”,但是代码的结尾不是 DropsRemaining 的 -1,而是将 DropsRemaining 设置为 -1。如果有人能帮助解决这个问题,我将不胜感激。
var sql = "SELECT DropsRemaining FROM UserData WHERE DiscordID LIKE " + message.author.id;
var DropCount = [];
connection.query(sql, function (err, result) {
if (!err)
setValue(result);
else
console.log("No Information For That User Found");
});
function setValue(value) {
DropCount = value;
console.log(DropCount);
};
//Remove drop from user
DropCount = DropCount - 1;
var sql = "UPDATE UserData SET DropsRemaining = " + DropCount + " WHERE DiscordID = " + message.author.id;
【问题讨论】: