Created
May 18, 2014 06:38
-
-
Save SomeKittens/15658ef0ac9e82cfdfea to your computer and use it in GitHub Desktop.
for loop bluebird promise
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
var userPromises = []; | |
// For loop instead of forEach to maintain `this` value | |
for (var i = 0; i < users.length; i++) { | |
userPromises.push(this.client.queryAsync('INSERT INTO invites (customerNo, email, name)' + | |
' VALUES ($1, $2, $3)', [req.user.id, users[i].email, users[i].name])); | |
} | |
return bluebird.all(userPromises); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment