Saturday, 8 April 2017

Nodejs - Normal callback vs exec

I've been learning nodejs for the last couple of stays and I stumbled upon something that I can't find any good explanations to.

Basically it's about exec vs a normal callback, i.e. (err, res) => {}, like this:

Product.find({}).exec((err, products) => {});

Product.find({}, (err, products) => {});

I find more examples that use exec, but when I read about exec I can't really understand why. They both seem to be doing the same thing to me.

So, my question is, should I be using one over the other, and if so, why?



via Chrillewoodz

No comments:

Post a Comment