chill117 / express-mysql-session

A MySQL session store for the express framework in node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An error with the latest version of promise-mysql

oira666 opened this issue · comments

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

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);
});

Closing this as it is likely resolved.