cqrs-eventdenormalizer
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -59,3 +59,3 @@ 'use strict'; | ||
this.denormFn = denormFn; | ||
if (denormFn.length === 2) { | ||
@@ -65,3 +65,3 @@ this.denormFn = function (evtData, vm, clb) { | ||
clb(null); | ||
} | ||
}; | ||
} | ||
@@ -290,5 +290,10 @@ | ||
if (this.query) { | ||
var query = this.query; | ||
if (!query && this.getQueryForThisViewBuilder) { | ||
query = this.getQueryForThisViewBuilder(evt); | ||
} | ||
if (query) { | ||
var notifications = []; | ||
this.findViewModels(this.query, function (err, vms) { | ||
this.findViewModels(query, function (err, vms) { | ||
if (err) { | ||
@@ -344,2 +349,21 @@ debug(err); | ||
}, | ||
/** | ||
* Inject useAsQuery function if no query and no id found. | ||
* @param {Function} fn The function to be injected. | ||
* @returns {ViewBuilder} to be able to chain... | ||
*/ | ||
useAsQuery: function (fn) { | ||
if (!fn || !_.isFunction(fn)) { | ||
var err = new Error('Please pass a valid function!'); | ||
debug(err); | ||
throw err; | ||
} | ||
this.getQueryForThisViewBuilder = function (evt) { | ||
return fn(evt); | ||
}; | ||
return this; | ||
} | ||
@@ -346,0 +370,0 @@ |
{ | ||
"author": "adrai", | ||
"name": "cqrs-eventdenormalizer", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -398,3 +398,3 @@ # Introduction | ||
// optional, if not defined or not found it will generate a new viewmodel with new id | ||
query: '{ group: 'admins' }', | ||
query: { group: 'admins' }, | ||
@@ -407,2 +407,6 @@ // optional, if not defined it will pass the whole event... | ||
}); | ||
// optional define a function to that returns a query that will be used as query to find the viewmodels (but do not define the query in the options) | ||
//.useAsQuery(function (evt) { | ||
// return { my: evt.payload.my }; | ||
//}); | ||
@@ -409,0 +413,0 @@ ## EventExtender |
@@ -0,1 +1,4 @@ | ||
## [v1.1.6](https://github.com/adrai/node-cqrs-eventdenormalizer/compare/v1.1.5...v1.1.6) | ||
- added possibility to denormalize multiple viewmodels in same collection with intelligent queries | ||
## [v1.1.5](https://github.com/adrai/node-cqrs-eventdenormalizer/compare/v1.1.4...v1.1.5) | ||
@@ -2,0 +5,0 @@ - async viewBuilders |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177833
3117
567