Can I use an async function as a callback? Something like this:
await sequelize.transaction(async function (t1) {
_.each(data, async function (value) {
await DoWork(value);
});
});
//Only after every "DoWork" is done?
doMoreWork();
As far as I understand there is no guarantee that the function invoking the callback will wait until the promise is solved before continuing. Right? The only way to be sure what will happen is to read the source code of the function the callback is passed to(e.g. source code of 'transaction')? Is there a good way to rewrite my sample to work properly no matter how the calling function is implemented?