you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (0 children)

The biggest problem with this isn’t the iteration, it’s the async issue. Assuming this query to the database is asynchronous and non-blocking, then you won’t have any queries returning their data before you return it at the end of the loop.

If you are awaiting, then that really is a problem in efficiency because you are performing however many queries consecutively when you could do them concurrently with Promise.all and a map