From 8f582fc8818d27a88bbac72c8d41bac920c8b70a Mon Sep 17 00:00:00 2001 From: Tim Fletcher Date: Wed, 16 Nov 2016 12:54:23 -0700 Subject: [PATCH] Add transform option --- aggregate.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aggregate.js b/aggregate.js index a27be45..463492a 100644 --- a/aggregate.js +++ b/aggregate.js @@ -2,7 +2,8 @@ ReactiveAggregate = function (sub, collection, pipeline, options) { var defaultOptions = { observeSelector: {}, observeOptions: {}, - clientCollection: collection._name + clientCollection: collection._name, + transform: function(doc) { return doc; } }; options = _.extend(defaultOptions, options); @@ -13,7 +14,8 @@ ReactiveAggregate = function (sub, collection, pipeline, options) { function update() { if (initializing) return; // add and update documents on the client - collection.aggregate(pipeline).forEach(function (doc) { + collection.aggregate(pipeline).forEach(function (result) { + const doc = options.transform(result); if (!sub._ids[doc._id]) { sub.added(options.clientCollection, doc._id, doc); } else {