4.0.0 • Published 5 months ago

mniam-store v4.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 months ago

NPM version Build Status Dependency Status

Mniam Store

mniam-store is a connect session store backed by mongodb

mniam is used to access as a access layer which means no async on init, simple configuration and seamless connection sharing if your app is using DB

mniam-store is compatible with express-session middleware

Installation

  $ npm install mniam-store

Options

  • db existing database created with mniam (can be shared with other parst of the app)
  • collection name of the mongo collection to keep sessions in (default: sessions)
  • maxAge - (seconds) specifies how long sessions should stay in DB - should be set-up to a value slightly larger than cookie.maxAge - defaults to 1 day

Usage

Similar to other connect session stores.

var connect = require('connect');
var mniam = require('mniam');
var MniamStore = require('mniam-store')(connect);

// use DB for mniam store only or share it with other parts of the app
var db = mniam.db('mongourl://localhost/database');

connect().use(connect.session({
  store: new MniamStore({
    db: db
  })
}));

Upgrading from 0.x

Since mniam-store is using mongo TTL index sessions created with previous versions will not expire automatically. We need to time stamp old sessions after the upgrade:

db.sessions.update(
  {_mod: {$exists:0}},
  {$currentDate:{_mod:true}},
  {multi:true}
);

And drop old index in expires:

db.sessions.dropIndex({expires:1});

License

MIT

4.0.0

5 months ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.0

5 years ago

1.2.2

7 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.1.0

11 years ago