diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-28 02:20:52 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-28 02:20:52 +0000 |
| commit | 4cff38c8f7b65dab1fd72ea835ea7288327d1056 (patch) | |
| tree | ac93acd69e77eef1e352af953d56238d70ea9c5d /node_modules/connect-mongo/src-es5/index.js | |
| parent | e11dd98c9a55cd1742d221e3b1ea90d31e240fa8 (diff) | |
Fixed admin bug
Diffstat (limited to 'node_modules/connect-mongo/src-es5/index.js')
| -rw-r--r-- | node_modules/connect-mongo/src-es5/index.js | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/node_modules/connect-mongo/src-es5/index.js b/node_modules/connect-mongo/src-es5/index.js index eaa929c..0e1b473 100644 --- a/node_modules/connect-mongo/src-es5/index.js +++ b/node_modules/connect-mongo/src-es5/index.js @@ -1,4 +1,5 @@ 'use strict'; +/* eslint indent: [error, 4] */ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -76,7 +77,6 @@ module.exports = function connectMongo(connect) { } /* Options */ - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(MongoStore).call(this, options)); _this.ttl = options.ttl || 1209600; // 14 days @@ -153,11 +153,11 @@ module.exports = function connectMongo(connect) { value: function setAutoRemoveAsync() { var _this3 = this; + var removeQuery = { expires: { $lt: new Date() } }; switch (this.autoRemove) { case 'native': return this.collection.ensureIndexAsync({ expires: 1 }, { expireAfterSeconds: 0 }); case 'interval': - var removeQuery = { expires: { $lt: new Date() } }; this.timer = setInterval(function () { return _this3.collection.remove(removeQuery, { w: 0 }); }, this.autoRemoveInterval * 1000 * 60); @@ -185,9 +185,10 @@ module.exports = function connectMongo(connect) { this.collection = collection; // Promisify used collection methods - ['count', 'findOne', 'remove', 'drop', 'update', 'ensureIndex'].forEach(function (method) { - collection[method + 'Async'] = Promise.promisify(collection[method], collection); + ['count', 'findOne', 'remove', 'drop', 'ensureIndex'].forEach(function (method) { + collection[method + 'Async'] = Promise.promisify(collection[method], { context: collection }); }); + collection.updateAsync = Promise.promisify(collection.update, { context: collection, multiArgs: true }); return this; } @@ -248,7 +249,7 @@ module.exports = function connectMongo(connect) { _this5.emit('touch', sid); return s; } - }).nodeify(callback); + }).asCallback(callback); } }, { key: 'set', @@ -260,7 +261,7 @@ module.exports = function connectMongo(connect) { delete session.lastModified; } - var s; + var s = void 0; try { s = { _id: this.computeStorageId(sid), session: this.transformFunctions.serialize(session) }; @@ -287,9 +288,15 @@ module.exports = function connectMongo(connect) { return this.collectionReady().then(function (collection) { return collection.updateAsync({ _id: _this6.computeStorageId(sid) }, s, { upsert: true }); - }).then(function () { - return _this6.emit('set', sid); - }).nodeify(callback); + }).then(function (responseArray) { + var rawResponse = responseArray.length === 2 ? responseArray[1] : responseArray[0].result; + if (rawResponse.upserted) { + _this6.emit('create', sid); + } else { + _this6.emit('update', sid); + } + _this6.emit('set', sid); + }).asCallback(callback); } }, { key: 'touch', @@ -329,7 +336,7 @@ module.exports = function connectMongo(connect) { } else { _this7.emit('touch', sid); } - }).nodeify(callback); + }).asCallback(callback); } }, { key: 'destroy', @@ -340,21 +347,21 @@ module.exports = function connectMongo(connect) { return collection.removeAsync({ _id: _this8.computeStorageId(sid) }); }).then(function () { return _this8.emit('destroy', sid); - }).nodeify(callback); + }).asCallback(callback); } }, { key: 'length', value: function length(callback) { return this.collectionReady().then(function (collection) { return collection.countAsync({}); - }).nodeify(callback); + }).asCallback(callback); } }, { key: 'clear', value: function clear(callback) { return this.collectionReady().then(function (collection) { return collection.dropAsync(); - }).nodeify(callback); + }).asCallback(callback); } }, { key: 'close', |
