Created
May 1, 2016 15:04
-
-
Save daveroma/e0e94c8d1b997008264f8fe2d4b10b30 to your computer and use it in GitHub Desktop.
Do something when a document is added to a MongoDB collection in Meteor
This file contains 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
Meteor.startup(function() { | |
let leadsLoaded = false; | |
let leadsCursor = Leads.find(); | |
Meteor.subscribe('leads', function() { | |
leadsLoaded = true; | |
}); | |
leadsCursor.observe({ | |
added: function(doc) { | |
if(leadsLoaded) { | |
const title = 'You Have a New Lead!'; | |
const body = `Name: ${doc.first_name} ${doc.last_name}`; | |
renderDesktopNotification(title, body); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment