npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

connect-session-knex

1.4.0 • Public • Published

Connect Session Knex

NPM Version NPM Downloads Node.js Version Build Status Dependency Status Coverage Status

NPM

connect-session-knex is an express-session store backed by Postgres, MySQL, MariaDB, MSSQL or SQLite3, via the knex.js library.

Installation

$ npm install connect-session-knex

Usage

Example application using the defaults

Example application with PostgreSQL

With Express 3 or Connect

Options

  • tablename='sessions' Tablename to use. Defaults to 'sessions'.
  • sidfieldname='sid' Field name in table to use for storing session ids. Defaults to 'sid'.
  • knex knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'
  • createtable if the table for sessions should be created automatically or not.
  • clearInterval milliseconds between clearing expired sessions. Defaults to 60000.

If the table does not exist in the schema, this module will attempt to create it unless the 'createtable' option is false.

If a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file named 'connect-session-knex.sqlite', in the working directory of the process.

Schema

PostgreSQL or SQLite

Table Name "sessions"

Column Type Modifiers Storage
sid character varying(255) not null extended
sess json not null extended
expired timestamp with time zone not null plain

Indexes:

    "sessions_pkey" PRIMARY KEY, btree (sid)  
    "sessions_expired_index" btree (expired)

Benchmarks

https://github.com/llambda/express-session-benchmarks

Keywords

none

install

npm i connect-session-knex

Downloadsweekly downloads

4,500

version

1.4.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability