2

Mongoose: Callbacks VS Promises? Opinions and reasons please.

I'm trying to update array of data which involves couple queries.. Best practices?

Comments
  • 1
    promises. callbacks are always used in a different say. But promises are standardized and are easy combinalble. E.g. with Promise.all
    And because of that, promises are the only way to go.
  • 1
    @plusgut thank you... Promises all the way :)
  • 0
    @biodunch you are welcome :)
    any other js related questions?
  • 0
    @plusgut have you used mongodb / mongoose?
  • 0
    None for now but will sure hit you up when I have one
  • 2
    Ehhh, whichever you fancy more tbh.

    Async is pretty nice too.

    Just try to learn them all or make the same code and use them each and see which you prefer.

    My only gripe with promises is if you forget to catch one, good luck.
  • 1
    @D--M I am yet to grab the correct usage of async / await :(
  • 2
    @biodunch

    Fair enough, i definitely recommend looking at it. Simplifes how code is read.
  • 1
    @D--M async/await is another reasonto use promises, without promises they don't work.
    @biodunch I did use it, but heard lots of bad things about it. They prioritize performance over safety. E.g. they safe the data in memory and tell you it's saved. But if the database would crash, your data would be lost. and that was/is theire default-setting.
Add Comment