The title speaks for itself, i am looking into tw ways to call a db function from an array of models to process
here is what i had
for(const x in arr ) {
await insertIntoDB(x);
}
but i was told by someone that this is handling them async and it much better performce and faster
const promises = [];
for(const x of arr ) {
promises.push( insertIntoDB() );
}
await Promise.all(promises);
or
await Promise.all(async arr.map(async x => insertIntoDB(x)));
I know js does not do true paralle operations but it does do it concurrently, so is there really any difference in calling the await wwithin al oop vs waiting till end? will they be processed in order or concurrently saving time?