Skip to content

Commit

Permalink
dont run getDocs in update or r remove hooks if no aspects are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
matb33 committed May 8, 2014
1 parent 0ae1f0f commit f1d2ac6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CollectionHooks.defineAdvice("remove", function (userId, _super, aspects, getTra
// args[0] : selector
// args[1] : callback

var docs = CollectionHooks.getDocs.call(self, collection, args[0]).fetch();
if (aspects.before || aspects.after) {
docs = CollectionHooks.getDocs.call(self, collection, args[0]).fetch();
}

// copy originals for convenience for the "after" pointcut
if (aspects.after) {
Expand Down
8 changes: 5 additions & 3 deletions update.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ CollectionHooks.defineAdvice("update", function (userId, _super, aspects, getTra
args[2] = {};
}

fields = getFields(args[1]);
docs = CollectionHooks.getDocs.call(self, collection, args[0], args[2]).fetch();
docIds = _.map(docs, function (doc) { return doc._id; });
if (aspects.before || aspects.after) {
fields = getFields(args[1]);
docs = CollectionHooks.getDocs.call(self, collection, args[0], args[2]).fetch();
docIds = _.map(docs, function (doc) { return doc._id; });
}

// copy originals for convenience for the "after" pointcut
if (aspects.after) {
Expand Down

0 comments on commit f1d2ac6

Please sign in to comment.