Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/express-session-mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var mongo = require('mongodb'),
var MongoStore = function(options) {
options = options || {};
Session.Store.call(this, options);

// Default reapInterval to 10 minutes
this.reapInterval = options.reapInterval || 600000;

Expand All @@ -23,10 +23,11 @@ var MongoStore = function(options) {
self.reap(self.maxAge);
}, this.reapInterval, this);
}

var server,
dbName = (options.db) ? options.db : 'express-sessions',
ip = (options.ip) ? options.ip : '127.0.0.1',
useNative = (options.native !== undefined) ? options.native : true,
port = (options.port) ? options.port : 27017;

this._collection = (options.collection) ? options.collection : 'sessions';
Expand All @@ -37,9 +38,9 @@ var MongoStore = function(options) {
server= new Server(ip, port, {auto_reconnect: true}, {});
}

this._db = new Db( dbName, server, { native_parser:true });
this._db = new Db( dbName, server, { native_parser: useNative });
this._db.open(function(db) {});

}

util.inherits(MongoStore, Session.Store);
Expand All @@ -65,7 +66,7 @@ MongoStore.prototype.set = function(sid, sess, fn) {
}
collection[method](sess, function(err, document) {
if (err) {
} else {
} else {
fn && fn(null, sess);
}
});
Expand All @@ -79,7 +80,7 @@ MongoStore.prototype.get = function(sid, fn) {
collection.findOne({ _sessionid: sid }, function(err, session_data) {
if (err) {
fn && fn(error);
} else {
} else {
if (session_data) {
session_data = cleanSessionData(session_data);
}
Expand Down Expand Up @@ -136,7 +137,7 @@ var cleanSessionData = function(json) {
data[i] = data[i].toNumber();
}
}

}
return data;
}
Expand Down