From e213aa4373b9e1286b85e84038a62e2b650c81ee Mon Sep 17 00:00:00 2001 From: raghav135 Date: Tue, 14 Feb 2017 12:45:08 +0530 Subject: [PATCH 1/2] Lock version of mongodb module to "2.2.22". --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e87d2e1..b7e1cc4 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "gridfs-stream": "^1.1.1", "lodash": "^4.6.1", "loopback-connector": "^2.3.0", - "mongodb": "^2.1.11", + "mongodb": "2.2.22", "string_decoder": "^0.10.31" }, "devDependencies": { From 51e23dccb21bb2359877c8a7e7422421e61b6be7 Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Tippa Date: Fri, 1 Sep 2017 17:03:58 +0530 Subject: [PATCH 2/2] Added options to all the exposed REST api methods --- lib/index.js | 60 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index cefce38..5d53f5f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -62,7 +62,11 @@ MongoStorage = (function() { } }; - MongoStorage.prototype.getContainers = function(callback) { + MongoStorage.prototype.getContainers = function(options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } return this.db.collection('fs.files').find({ 'metadata.mongo-storage': true }).toArray(function(err, files) { @@ -79,7 +83,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.getContainer = function(name, callback) { + MongoStorage.prototype.getContainer = function(name, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } return this.db.collection('fs.files').find({ 'metadata.mongo-storage': true, 'metadata.container': name @@ -94,7 +102,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.destroyContainer = function(name, callback) { + MongoStorage.prototype.destroyContainer = function(name, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var self; self = this; return self.getFiles(name, function(err, files) { @@ -107,7 +119,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.upload = function(container, req, res, callback) { + MongoStorage.prototype.upload = function(container, req, res, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var busboy, promises, self; self = this; busboy = new Busboy({ @@ -158,14 +174,22 @@ MongoStorage = (function() { return file.pipe(stream); }; - MongoStorage.prototype.getFiles = function(container, callback) { + MongoStorage.prototype.getFiles = function(container, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } return this.db.collection('fs.files').find({ 'metadata.mongo-storage': true, 'metadata.container': container }).toArray(callback); }; - MongoStorage.prototype.removeFile = function(container, filename, callback) { + MongoStorage.prototype.removeFile = function(container, filename, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var self; self = this; return self.getFile(container, filename, function(err, file) { @@ -176,7 +200,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.removeFileById = function(id, callback) { + MongoStorage.prototype.removeFileById = function(id, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var self; self = this; return async.parallel([ @@ -206,7 +234,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.getFile = function(container, filename, callback) { + MongoStorage.prototype.getFile = function(container, filename, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } return this.__getFile({ 'metadata.mongo-storage': true, 'metadata.container': container, @@ -235,7 +267,11 @@ MongoStorage = (function() { return read.pipe(res); }; - MongoStorage.prototype.downloadById = function(id, res, callback) { + MongoStorage.prototype.downloadById = function(id, res, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var self; if (callback == null) { callback = (function() {}); @@ -249,7 +285,11 @@ MongoStorage = (function() { }); }; - MongoStorage.prototype.download = function(container, filename, res, callback) { + MongoStorage.prototype.download = function(container, filename, res, options, callback) { + if (callback === undefined && typeof options === 'function') { + callback = options; + options = undefined; + } var self; if (callback == null) { callback = (function() {});