Experienced software engineer who is result oriented with a passion for developing innovative solutions to business problems.
Also passionate about charity and human rights
Thank you @romeerez for your concern for good content which I agree with you that we should hold ouselves to a better standard. However, your opening statement just isn't true because the article has since been updated before your comment.
The article isn't describing n+1 problem as that isn't peculiar to Node.js.
Sorry! My bad, really, I read it before and yesterday just very briefly looked through and I see the same problem, I see section about event loop so I thought it wasn't changed
As for N+1, it's the way how you're loading nextOfKin with Promise.all, it's not a proper solution for a problem.
In the example you're using locally defined data and setTimeout to simulate delay, in real world it will most likely be a database or API call.
In case of API call, Promise.all would be ok only if you have no other choice, and in case of database call this Promise.all will consume whole connection pool and block other users from accessing database, Necmettin Begiter and Tobias Nickel mentioned this in comments.
Like, if you awaiting 100 promises, and have just 10 available connections, it won't be fast and other users won't be able to make a query in the meantime.
So I was concerned that new comers may take this article as a teaching material and will go and implement it this way on real projects. But since you're editing it and taking care of it - that's good, wish you success
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you @romeerez for your concern for good content which I agree with you that we should hold ouselves to a better standard. However, your opening statement just isn't true because the article has since been updated before your comment.
The article isn't describing n+1 problem as that isn't peculiar to Node.js.
Anyway, thank you for your concern.
Sorry! My bad, really, I read it before and yesterday just very briefly looked through and I see the same problem, I see section about event loop so I thought it wasn't changed
As for N+1, it's the way how you're loading nextOfKin with Promise.all, it's not a proper solution for a problem.
In the example you're using locally defined data and setTimeout to simulate delay, in real world it will most likely be a database or API call.
In case of API call, Promise.all would be ok only if you have no other choice, and in case of database call this Promise.all will consume whole connection pool and block other users from accessing database, Necmettin Begiter and Tobias Nickel mentioned this in comments.
Like, if you awaiting 100 promises, and have just 10 available connections, it won't be fast and other users won't be able to make a query in the meantime.
So I was concerned that new comers may take this article as a teaching material and will go and implement it this way on real projects. But since you're editing it and taking care of it - that's good, wish you success