Node.js pool.query和函数

时间:2019-01-30 10:20:45

标签: node.js

我在atm编码vgo赌博网站。而且我遇到了一个问题。我无法使它正常工作,我也无法弄清楚为什么。有人知道问题出在哪里吗?

         if(msg.startsWith('/cancelflip') && ( user.rank == 100)) {
         if(args = /^\/cancelflip ([0-9]*)/.exec(msg)) {
                pool.query('SELECT citemss FROM cfs WHERE id = ?', [args[1]], function(e,r) {
                    if(e) throw e;
                pool.query('SELECT cuser FROM cfs WHERE id = ?', [args[1]], function(er, ro) {
                    if(er) throw er;
                pool.query('SELECT tradelink FROM users WHERE uid = ?', ro[0].cuser, function(err, ror) {
                    if(err) throw err;

                var items_p1 = r[0].citemss.split(',');

                ET.ITrade.SendOffer({trade_url: ror[0].tradelink, items_to_send: items_p1.join(','), expiration_time: 86400, message: 'VGODiamond.net - Cancelled Coinflip'}, (err, res) => {
                    if(err) throw err;

            if(!res.hasOwnProperty('response')) return socket.emit('msg', res.message, "error");

            if(res.response.offer.state == 2) {
                Offers[res.response.offer.id] = {
                    user: user.uid,
                };
            }

                socket.emit('user trade', res.response.offer.id);
                });

        });
    });
});
                pool.query('DELETE FROM cfs WHERE id = ?', [args[1]], setTimeout(function(errr, rorr) {
                    delete CFs[args[1]];

                    io.sockets.emit('coinflip', 'remove', [args[1]]);

                    sendCFStatistics();
                }, 3000));
    }
}

1 个答案:

答案 0 :(得分:0)

通过在删除行查询中设置计时器来解决该问题。