Large Transaction Update
This commit is contained in:
@@ -186,6 +186,7 @@ exports.UserStorage = class UserStorage extends Storage {
|
||||
*/
|
||||
checkBalance(_tokensToBeUsed, _account_id, callback) {
|
||||
if (!_account_id) return callback(new Error("Account not specified when checking account balance"), undefined);
|
||||
log.DEBUG("Tokens to verify against balance", _tokensToBeUsed, _account_id);
|
||||
if (!_tokensToBeUsed && !_tokensToBeUsed >= 0) return callback(new Error("Specified tokens are invalid when checking account balance"), undefined);
|
||||
this.getRecordBy('account_id', _account_id, (err, record) => {
|
||||
if (err) return callback(err, undefined);
|
||||
@@ -214,11 +215,11 @@ exports.UserStorage = class UserStorage extends Storage {
|
||||
switch(_updateType){
|
||||
case "withdraw":
|
||||
// Code here to withdraw funds
|
||||
sqlQuery = `UPDATE ${this.dbTable} SET balance=balance-${_updateAmount} WHERE discord_account_id = ${_account_id};`;
|
||||
sqlQuery = `UPDATE ${this.dbTable} SET balance=balance-${_updateAmount} WHERE discord_account_id = ${_discord_account_id};`;
|
||||
break;
|
||||
case "deposit":
|
||||
// Code here to withdraw funds
|
||||
sqlQuery = `UPDATE ${this.dbTable} SET balance=balance+${_updateAmount} WHERE discord_account_id = ${_account_id};`;
|
||||
sqlQuery = `UPDATE ${this.dbTable} SET balance=balance+${_updateAmount} WHERE discord_account_id = ${_discord_account_id};`;
|
||||
break;
|
||||
default:
|
||||
log.ERROR('Update type not valid: ', _updateType);
|
||||
|
||||
Reference in New Issue
Block a user