1.1.1 • Published 6 years ago

knex-pg-store v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Knex Logo

KnexJS' A batteries-included, multi-dialect query builder

Installation

$ npm install -g knex-pg-store

Usage

Examples are based on Express 4.

Simple example:

const KnexStore = require('knex-pg-store');

app.use(session({
  store: new KnexStore(knex, {
      tableName: 'sessions',
      gcFrecuency: 10000,
      browserSessionLifetime: 86400 * 1000
  }),
  secret: process.env.FOO_COOKIE_SECRET,
  resave: false,
  cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days
}));

Advanced options

  • schemaName - Name of the schema in the database (default: public).
  • tableName - Name of the session table in the database (default: sessions).
  • sync - Create the sessions table if it doesnt exist (default: false).
  • syncTimeout - If sync is true, how long to wait, in ms, for the sync to complete (default: 3000)
  • gcFrecuency - Do garbage collection after approximately this many requests. This deletes expired session data from the table. Set to 0 to never do garbage collection. (default: 10000, or approximately every 10,000 requests)
  • timestamps - If true, the table will have updated_at and created_at columns. (default: false)
  • browserSessionLifetime - How long, in ms, to remember sessions without a TTL: sessions that only last until the browser is closed. Some session managers, will ignore this and use a reasonable default. (default: 86400000)

License

MIT

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago