Skip to content

Instantly share code, notes, and snippets.

@itaditya
Last active July 2, 2017 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itaditya/bcd589116c566f73d8d5d6fc018b53d5 to your computer and use it in GitHub Desktop.
Save itaditya/bcd589116c566f73d8d5d6fc018b53d5 to your computer and use it in GitHub Desktop.
Mongoose functions
User.find({
verified: false
}).exec(function (err, users) {
var n = users.length;
for (var i = 0; i < n; i++) {
var user = users[i];
sendEmail(user.email);
}
})
User.find({
verified: false
}).stream().on('data', function (user) {
sendMail(user.email)
}).on('end', function () {
console.log("sent mail to all users")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment