lib/mongostore.js
function MongoStore(uri, options) {
        var self = this;

        this.options = options || (options = {});
        options.collectionName = options.collectionName || 'sessions';
        // 1 day
        options.ttl = options.ttl || 24 * 60 * 60 * 1000;
        // 60 s
        options.cleanupInterval = options.cleanupInterval || 60 * 1000;
        options.server = options.server || {};
        options.server.auto_reconnect = options.server.auto_reconnect != null ? options.server.auto_reconnect : true;

        this._error = function(err) {
            if (err) { self.emit('error', err); }
        };

        // It's a Db instance.
        if (uri.collection) {
            this.db = uri;
            this._setup();
        } else {
            MongoClient.connect(uri, options, function(err, db) {
                if (err) { return self._error(err); }
                self.db = db;
                self._setup();
            });
        }
    }
function MongoStore(uri, options) {
        var self = this;

        this.options = options || (options = {});
        options.collectionName = options.collectionName || 'sessions';
        // 1 day
        options.ttl = options.ttl || 24 * 60 * 60 * 1000;
        // 60 s
        options.cleanupInterval = options.cleanupInterval || 60 * 1000;
        options.server = options.server || {};
        options.server.auto_reconnect = options.server.auto_reconnect != null ? options.server.auto_reconnect : true;

        this._error = function(err) {
            if (err) { self.emit('error', err); }
        };

        // It's a Db instance.
        if (uri.collection) {
            this.db = uri;
            this._setup();
        } else {
            MongoClient.connect(uri, options, function(err, db) {
                if (err) { return self._error(err); }
                self.db = db;
                self._setup();
            });
        }
    }
function MongoStore ( uri , options ) { var self = this ; this . options = options || ( options = { } ) ; options . collectionName = options . collectionName || 'sessions' ; // 1 day options . ttl = options . ttl || 24 * 60 * 60 * 1000 ; // 60 s options . cleanupInterval = options . cleanupInterval || 60 * 1000 ; options . server = options . server || { } ; options . server . auto_reconnect = options . server . auto_reconnect != null ? options . server . auto_reconnect : true ; this . _error = function ( err ) { if ( err ) { self . emit ( 'error' , err ) ; } } ; // It's a Db instance. if ( uri . collection ) { this . db = uri ; this . _setup ( ) ; } else { MongoClient . connect ( uri , options , function ( err , db ) { if ( err ) { return self . _error ( err ) ; } self . db = db ; self . _setup ( ) ; } ) ; } }
Initialize a new `MongoStore`.

@api public
Initialize a new MongoStore .