Skip to content

Instantly share code, notes, and snippets.

@johnantoni
Created March 18, 2018 20:33
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 johnantoni/f13a55080b56aff41389c3e575928595 to your computer and use it in GitHub Desktop.
Save johnantoni/f13a55080b56aff41389c3e575928595 to your computer and use it in GitHub Desktop.
es6 promises
const save = () => {
return new Promise((resolve, reject) => {
// access the db
// save the file
// when the file is saved successfully
// resolve with the saved document
resolve(doc)
// if there was an error
reject(err)
})
}
save() //
{
then:
catch:
}
// const user = new User()
//
// user
// .save()
// .then(function(doc) {
//
// })
// .catch()
//
//
//
// {
// then: (doc)
// catch: (err)
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment