Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 {
Expand Down