Search code examples
node.jspostgresqlexpressexpress-session

how to point connect-session-sequelize session store to required database schema


In my Node.js application using express-session for session management and connect-session-sequelize for storing session (persistent storage - Postgres) .

I have created a schema (e.g: myschema) in my database which exists apart from the default public and I want to point my session storage to myschema. By default connect-session-sequelize library is pointing to public schema and cannot find an option/parameter to change database schema.

Please help!


Solution

  • I have posted the same issue in the github library. The owner has closed the issue mentioning that schema configuration must be set at database object.

    But, I do not think that is correct because

    1. if db object is specific to particular schema it will be difficult to access other schemas in the same database.
    2. Also, it is breach of design principles to create db object for each db schema.
    3. Moreover, Sequelize does not allow to configure schema.

    This is an issue in connect-session-sequelize, so make sure you do not have such requirement (pointing to custom schema) while using this library.