0

I am currently working on a project with mongoDB and am receiving this notification in the terminal:

"DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"

I am fairly new to mongo and have no idea what these "promises" are. I also checked out the link in the notification, but still cannot understand what it is saying.

If someone could please explain what "promises" are within mongodb and what I should do about this deprecation, that would be great. Thanks!

jblew
  • 274
  • 1
  • 8
  • 21
  • The linked article is really quite clear about this. What, specifically, don't you understand? – T.J. Crowder Apr 14 '17 at 18:20
  • Promises deal with async operations. They are wrappers for values that are not available yet. They are not a mongodb specific thing, actually that's what this message is about, that they deprecated their implementation of this pattern, and want you to plug in a more sophisticated/performant implementation. imo. [Q](https://github.com/kriskowal/q) and [bluebird](http://bluebirdjs.com) have set the bar, but nowadays every Browser and Nodejs provides a basic Promise implementation. Just google the topic, there are plenty of articles. – Thomas Apr 14 '17 at 18:28
  • @T.J.Crowder I just don't understand what exactly a promise is. Now I get that they are similar to callbacks – jblew Apr 14 '17 at 18:56
  • @Thomas Thanks Thomas! This helps a ton – jblew Apr 14 '17 at 18:57

1 Answers1

2

Promises in MongoDB are just like promises in the larger JS ecosystem. They are an alternative to callback functions which allow for step-by-step orderly execution of asynchronous code.

As your Mongo link, shows, for example, you can use Promise.then() instead of a callback function.

Here is some further discussion.

Here are some other promise implementations:

  1. Bluebird
  2. jQuery
  3. Native ES6/ES2015+ Promises
Community
  • 1
  • 1
John Vandivier
  • 2,158
  • 1
  • 17
  • 23