Comparing version 1.0.6 to 1.0.7
@@ -6,3 +6,2 @@ 'use strict'; | ||
; | ||
var async = require('async') | ||
function parallel(tasks, fn) { | ||
@@ -9,0 +8,0 @@ var errors = [], counter = 0, limit = Object.keys(tasks).length, results = {}; |
{ | ||
"name": "datamodel", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
@@ -130,2 +130,30 @@ # Datamodel | ||
### transform(Function callback) | ||
You can only call `transform` once. | ||
So, if you need to apply two transforms, put them both in the same transform callback. | ||
Example: | ||
```javascript | ||
return datamodel() | ||
.append('years', function(req, fill) { | ||
coll | ||
.aggregate( | ||
{ $project: { Py: 1, _id: 0} }, | ||
{ $group: { _id: "$Py", occ: { $sum: 1} } }) | ||
.then(fill) | ||
.catch(fill); | ||
}) | ||
.transform(function(req, fill) { | ||
var n = this; | ||
var y = {}; | ||
this.years.each(function (e) { | ||
y[e._id] = e.occ; | ||
}); | ||
n.years = y; | ||
fill(n); | ||
}) | ||
``` | ||
### send(Function callback) | ||
@@ -132,0 +160,0 @@ ### apply(Mixed input, Mixed output, Function callback) |
19667
167
505