I am trying to using my existing connection pool with express-mysql-session, however, in doing so i am unable to specify the database name.
My app connected to multiple databases which is why I am not setting database name in mysql2 createPool options.
const sessionStore = new MySQLStore({ database: "db_name" }, pool);
app.use(
session({
key: `APP_${process.env.NODE_ENV}`,
secret: process.env.SESSION_SECRET,
store: sessionStore,
resave: false,
saveUninitialized: false,
clearExpired: true,
checkExpirationInterval: 900000,
cookie: {
secure: process.env.NODE_ENV === "production" ? true : false,
maxAge: 2629800000,
},
})
);
this results in:
code: 'ER_NO_DB_ERROR',
errno: 1046,
sql: "SELECT `data` AS data, `expires` as expires FROM `sessions` WHERE `session_id` = '[REDACTED]'",
sqlState: '3D000',
sqlMessage: 'No database selected'
Is there a way to make this work or do i need to keep using 2 separate connection pools?
I am trying to using my existing connection pool with express-mysql-session, however, in doing so i am unable to specify the database name.
My app connected to multiple databases which is why I am not setting database name in mysql2
createPooloptions.this results in:
Is there a way to make this work or do i need to keep using 2 separate connection pools?