diff --git a/lib/express-session-mongo.js b/lib/express-session-mongo.js index 94bbeaf..11c3539 100644 --- a/lib/express-session-mongo.js +++ b/lib/express-session-mongo.js @@ -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; @@ -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'; @@ -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); @@ -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); } }); @@ -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); } @@ -136,7 +137,7 @@ var cleanSessionData = function(json) { data[i] = data[i].toNumber(); } } - + } return data; }