From eadcecc7c5624991683152b2299525a8e293f8bd Mon Sep 17 00:00:00 2001 From: Alexey Shchur Date: Wed, 8 Jul 2020 12:34:32 +0300 Subject: [PATCH 1/2] fix: collation for find operation (#591) --- lib/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index c802c5c..dc637bd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -143,11 +143,13 @@ DataStore.prototype.find = function({query, collection, options = {}, schema}) { } else { query = this.prepareQuery(query, schema) - debug('find in %s %o %o', collection, query, options) + const extendedOptions = Object.assign({}, options, this.getExtraOptionsByOperation('find')) + + debug('find in %s %o %o', collection, query, extendedOptions) this.database .collection(collection) - .find(query, options, (err, cursor) => { + .find(query, extendedOptions, (err, cursor) => { if (err) return reject(err) cursor @@ -655,4 +657,11 @@ DataStore.prototype.dropDatabase = function(collectionName) { }) } +DataStore.prototype.getExtraOptionsByOperation = function(operationName){ + const configKey = "extra_options_by_operation"; + const extraOptionsPerOperationConfig = this.config.has(configKey) ? this.config.get(configKey) : {}; + console.log({extraOptionsPerOperationConfig}); + return extraOptionsPerOperationConfig[operationName] || {} +} + module.exports = DataStore From 16ef1f2c7589f89addf0fa6905e020e01f26c4ec Mon Sep 17 00:00:00 2001 From: Alexey Shchur Date: Wed, 8 Jul 2020 12:39:26 +0300 Subject: [PATCH 2/2] chore: remove console.log --- lib/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index dc637bd..3ba5a16 100644 --- a/lib/index.js +++ b/lib/index.js @@ -660,7 +660,6 @@ DataStore.prototype.dropDatabase = function(collectionName) { DataStore.prototype.getExtraOptionsByOperation = function(operationName){ const configKey = "extra_options_by_operation"; const extraOptionsPerOperationConfig = this.config.has(configKey) ? this.config.get(configKey) : {}; - console.log({extraOptionsPerOperationConfig}); return extraOptionsPerOperationConfig[operationName] || {} }