Node.js mysql回调错误

时间:2015-09-23 01:24:12

标签: mysql node.js callback

我使用了node.js和mysql。 我在mysql查询回调中做了回调函数。

exports.callback = function(req) 
{
....
    Mysqldb.pool.getConnection(function(err, db) {
        db.query("select * from tbl"), function (err,rows) {      
          db.query("update tbl set id = 1"), function (err, rows){
          }); //update tbl
       });//select tbl
    }); //getconnection
}; //export.callback

错误是更新查询回调.... 错误信息是

TypeError: this._callback.apply is not a function
at Query.Sequence.end (c:\redfox_server_src\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
at Query.ErrorPacket (c:\redfox_server_src\node_modules\mysql\lib\protocol\sequences\Query.js:94:8)
at Protocol._parsePacket (c:\redfox_server_src\node_modules\mysql\lib\protocol\Protocol.js:274:23)
at Parser.write (c:\redfox_server_src\node_modules\mysql\lib\protocol\Parser.js:77:12)
at Protocol.write (c:\redfox_server_src\node_modules\mysql\lib\protocol\Protocol.js:39:16)
at Socket.<anonymous> (c:\redfox_server_src\node_modules\mysql\lib\Connection.js:96:28)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)

请帮帮我..

1 个答案:

答案 0 :(得分:2)

你错过了双引号。

错:

db.query("select * from tbl)

右:

db.query("select * from tbl")