@ariel-biton-sharecare/connect-session-knex
v3.0.3
Published
A knex.js session store for Express and Connect (temp fork to support knex 2.1.0)
Downloads
4
Readme
Temporary fork to work with Knex 2.1.0
Connect Session Knex
connect-session-knex is an express-session store backed by PostgreSQL, MySQL, MariaDB, MSSQL, Oracle or SQLite3, via the knex.js library.
Installation
$ npm install connect-session-knex
History
See Changelog.md
Usage
Example application using the defaults
Example application with PostgreSQL
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.disableDbCleanup
disables the automatic clearing of expired sessions. Defaults to false.
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/gx0r/express-session-benchmarks
Testing
Install Postgresql
Instructions for Ubuntu after intalling the db:
sudo -u postgres psql
CREATE DATABASE travis_ci_test OWNER postgres;
GRANT all privileges ON DATABASE travis_ci_test TO postgres;
ALTER USER postgres WITH PASSWORD 'postgres';
\q
Install Mysql
Instructions for Ubuntu after installing the db:
sudo mysql -u root
create user 'travis' identified by 'travis';
ALTER USER 'travis'@'localhost' IDENTIFIED BY 'travis';
create database travis_ci_test;
grant all on travis_ci_test.* to 'travis';
\q
sudo service mysql restart
Make sure both the MySQL and Postgres services are running
npm run test