Last active
June 10, 2017 20:11
-
-
Save patarkf/300715c6cf9216251ef6d90a2feaaedd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let promise = Promise.resolve(); | |
const posts = [{}, {}, {}]; | |
posts.forEach(post => { | |
promise = promise.then(() => { | |
return db.insert(post); | |
}); | |
}); | |
promise.then(() => { | |
// now all our docs have been saved | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment