Skip to content

Instantly share code, notes, and snippets.

@davidworkman9
Created February 18, 2014 22:23
Show Gist options
  • Save davidworkman9/9081673 to your computer and use it in GitHub Desktop.
Save davidworkman9/9081673 to your computer and use it in GitHub Desktop.
Assumes meteor collection-hooks is installed.
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