Skip to content

No "on" method for pool object #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shaalin opened this issue Aug 1, 2013 · 5 comments
Closed

No "on" method for pool object #561

shaalin opened this issue Aug 1, 2013 · 5 comments

Comments

@shaalin
Copy link

shaalin commented Aug 1, 2013

I am seeing this issue using "2.0.0-alpha8".

Code Snippet :

var config = app.get('config');
this.pool = mysql.createPool(config.database.options);
this.pool.on('connection', function(err, connection){
    connection.query('some session related query');
})
var self = this;
this.pool.getConnection(function(err, connection) {
    if (!err) {
        callback(null);
    } else {
        callback(err);
    }
});
@apparatusdeus
Copy link

Pool.on is inherited from EventEmitter part of node.js standard library 'events' and is inherited using 'inherit' from the node.js standard library 'util'. I would hazard a guess that you need to update your version of Node.js

@euglv
Copy link

euglv commented Aug 24, 2013

I installed the latest node.js recently (0.10.17) and have the same issue.

@euglv
Copy link

euglv commented Aug 24, 2013

There is no "on" method in the documentation for 2.0.0-alpha8 version:
https://github.com/felixge/node-mysql/tree/v2.0.0-alpha8

So to use this method you need to download master branch of node-mysql.

@dougwilson
Copy link
Member

This issue can be closed. The reason you are getting the error is because you are not using at least v2.0.0-alpha9 as before then, the pool object was not an event emitter, so it had no on method.

@kai-koch
Copy link
Collaborator

Feel free to reopen, if your problem still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants