Created
February 18, 2014 22:23
-
-
Save davidworkman9/9081673 to your computer and use it in GitHub Desktop.
Assumes meteor collection-hooks is installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var my_coll = new Meteor.Collection('my_coll'), | |
triggers = new Meteor.Collection('triggers'), | |
TRIGGER_TYPES = [ greaterThanFive: 'greaterThanFive' ]; | |
my_coll.after.update(function (userId, doc, fieldNames, modifier, options) { | |
if (doc.count > 5) { | |
_.each(triggers.find({ on: TRIGGER_TYPES.greaterThanFive }).fetch(), function (trig) { | |
switch (trig.event) { | |
case 'email': | |
Email.send(trig.to, { html: trig.markup }); | |
break; | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment