chill117 / express-mysql-session

A MySQL session store for the express framework in node
MIT License
313 stars 106 forks source link

An error with the latest version of promise-mysql #107

Closed oira666 closed 3 years ago

oira666 commented 4 years ago

Hello! When I install the latest version of promise-mysql@4.1.3 I get an error (With previous version it works perfectly).

                var promise = this.connection.query(sql, params, done);
                                              ^

TypeError: this.connection.query is not a function
    at MySQLStore.query (O:\workshop\oshofest\cabinet\node_modules\express-mysql-session\index.js:432:33)
    at MySQLStore.<anonymous> (O:\workshop\oshofest\cabinet\node_modules\express-mysql-session\index.js:133:9)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

express_session_error

chill117 commented 4 years ago

Looks like there were some breaking changes in the promise-mysql module:

The main difference is that mysql.createPool now returns a promise. Besides this, the API is the same and you should be able to upgrade straight to v4. The only other difference is the extra options in the connectionOptions object.

I've added an integration test specifically for promise-mysql to verify that the module is still compatible with express-mysql-session - which it is. Usage with promise-mysql is as follows:

var MySQLStore = require('express-mysql-session');
var mysql = require('promise-mysql');

mysql.createPool({
    // db configuration options
}).then(function(connection) {
    var sessionStore = new MySQLStore({
        // express-mysql-session options
    }, connection);
}).catch(function(error) {
    console.error(error);
});
chill117 commented 3 years ago

Closing this as it is likely resolved.