express-mongoose-store
Advanced tools
Comparing version 1.0.1 to 1.0.2
16
index.js
@@ -6,2 +6,3 @@ module.exports = function(session, mongoose){ | ||
, debug = require('debug')('mongoose-store') | ||
, one_day = 1000 * 60 * 60 * 24 | ||
; | ||
@@ -22,9 +23,6 @@ | ||
var Session = mongoose.model('Session', session_schema) | ||
, one_day = 1000 * 60 * 60 * 24 | ||
; | ||
function MongooseStore(options) { | ||
options = options || {}; | ||
Store.call(this, options); | ||
this.Session = mongoose.model(options.modelName || 'Session', session_schema); | ||
this.ttl = options.ttl || one_day; | ||
@@ -37,3 +35,3 @@ }; | ||
debug('GET %s', sid); | ||
Session.findOne({ sid: sid }) | ||
this.Session.findOne({ sid: sid }) | ||
.exec(function(err, data){ | ||
@@ -93,3 +91,3 @@ if(err){ | ||
Session.findOneAndUpdate({ sid: sid }, s, { upsert: true }) | ||
this.Session.findOneAndUpdate({ sid: sid }, s, { upsert: true }) | ||
.exec(function(err, data){ | ||
@@ -120,3 +118,3 @@ if(err){ | ||
debug('DESTROY %s', sid); | ||
Session.findOneAndRemove({ sid: sid }) | ||
this.Session.findOneAndRemove({ sid: sid }) | ||
.exec(function(err, data){ | ||
@@ -135,3 +133,3 @@ if(err){ | ||
debug('CLEARALL'); | ||
Session.remove({}) | ||
this.Session.remove({}) | ||
.exec(function(err, data){ | ||
@@ -151,3 +149,3 @@ if(err){ | ||
debug('KEEPALIVE Querying Mongoose for empty set.'); | ||
Session.find({ noexits: true }, function(err, data){ | ||
this.Session.find({ noexits: true }, function(err, data){ | ||
if(err){ | ||
@@ -154,0 +152,0 @@ debug('KEEPALIVE error, %s', err); |
{ | ||
"name": "express-mongoose-store", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Session store for people who want to use MongoDB sessions, and already have a MongooseJS connection for their backend.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
9181
205