Created
April 16, 2020 18:41
-
-
Save itashdv/da87bbe7615f64277b1c8654b91daf54 to your computer and use it in GitHub Desktop.
Using promises in Mongoose
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
| Schema.methods.saveAsync = function () { | |
| return new Promise((resolve, reject) => { | |
| this.save((err) => { | |
| if (err) return reject(err) | |
| resolve(this) | |
| }) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment