Last active
July 2, 2017 05:28
-
-
Save itaditya/bcd589116c566f73d8d5d6fc018b53d5 to your computer and use it in GitHub Desktop.
Mongoose functions
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
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); | |
} | |
}) |
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
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