diff --git a/lib/query/hypernova/hypernova.js b/lib/query/hypernova/hypernova.js index 5cf7fd9..74210c3 100644 --- a/lib/query/hypernova/hypernova.js +++ b/lib/query/hypernova/hypernova.js @@ -11,7 +11,10 @@ function hypernova(collectionNode, userId) { }); } -export default function hypernovaInit(collectionNode, userId, config = {bypassFirewalls: false, params: {}}) { +export default function hypernovaInit(collectionNode, userId, config = {}) { + const bypassFirewalls = config.bypassFirewalls || false; + const params = config.params || {}; + let {filters, options} = applyProps(collectionNode); const collection = collectionNode.collection; diff --git a/lib/query/nodes/reducerNode.js b/lib/query/nodes/reducerNode.js index c5839d6..f0d2f26 100644 --- a/lib/query/nodes/reducerNode.js +++ b/lib/query/nodes/reducerNode.js @@ -12,10 +12,10 @@ export default class ReducerNode { * @param {*} args */ compute(object, ...args) { - object[this.name] = this.reduce.call(null, object, ...args); + object[this.name] = this.reduce.call(this, object, ...args); } reduce(object, ...args) { - return this.reduceFunction.call(null, object, ...args); + return this.reduceFunction.call(this, object, ...args); } } \ No newline at end of file diff --git a/lib/query/testing/bootstrap/authors/links.js b/lib/query/testing/bootstrap/authors/links.js index 5f39d85..a885c42 100644 --- a/lib/query/testing/bootstrap/authors/links.js +++ b/lib/query/testing/bootstrap/authors/links.js @@ -63,5 +63,13 @@ Authors.addReducers({ return object.profile.firstName + ' ' + object.profile.lastName; } + }, + paramBasedReducer: { + body: { + _id: 1, + }, + reduce(object, params) { + return params.element; + } } }); \ No newline at end of file diff --git a/lib/query/testing/reducers.server.test.js b/lib/query/testing/reducers.server.test.js index d43975e..4fc8d52 100644 --- a/lib/query/testing/reducers.server.test.js +++ b/lib/query/testing/reducers.server.test.js @@ -154,4 +154,24 @@ describe('Reducers', function () { }) }) }); -}); \ No newline at end of file + + it('Should work with params reducers', function () { + const query = createQuery({ + authors: { + $options: {limit: 1}, + paramBasedReducer: 1, + } + }); + + query.setParams({ + element: 'TEST_STRING' + }); + + const data = query.fetch(); + + assert.isTrue(data.length > 0); + data.forEach(author => { + assert.equal(author.paramBasedReducer, 'TEST_STRING'); + }) + }); +});