diff --git a/lib/index.js b/lib/index.js index 0735583..5357846 100644 --- a/lib/index.js +++ b/lib/index.js @@ -50,14 +50,14 @@ Cacher.prototype.run = function run(options) { /** * Run given manual query */ -Cacher.prototype.query = function query(sql) { - return this.rawFromCache(sql); +Cacher.prototype.query = function query(sql, options) { + return this.rawFromCache(sql, options); }; /** * Fetch data from cache for raw type query */ -Cacher.prototype.rawFromCache = function rawFromCache(sql) { +Cacher.prototype.rawFromCache = function rawFromCache(sql, options) { var self = this; return new Promise(function promiser(resolve, reject) { var key = self.key(sql); @@ -66,7 +66,7 @@ Cacher.prototype.rawFromCache = function rawFromCache(sql) { return reject(err); } if (!res) { - return self.rawFromDatabase(key, sql).then(resolve, reject); + return self.rawFromDatabase(key, sql, options).then(resolve, reject); } self.cacheHit = true; try { @@ -81,10 +81,11 @@ Cacher.prototype.rawFromCache = function rawFromCache(sql) { /** * Fetch raw query from the database */ -Cacher.prototype.rawFromDatabase = function rawFromDatabase(key, sql) { +Cacher.prototype.rawFromDatabase = function rawFromDatabase(key, sql, options) { var self = this; return new Promise(function promiser(resolve, reject) { - return self.sequelize.query(sql, { type: self.sequelize.QueryTypes.SELECT }) + if (!options) options = { type: self.sequelize.QueryTypes.SELECT }; + return self.sequelize.query(sql, options) .then(function then(results) { var res; if (!results) {