Saturday 26 November 2016

Need help/opinions for async DB saving convention and practice

Hey there good people, I have a question: Say I have a blog with an Article model and each article has a Category model which is in the DB. Then, the Category has an array of Articles that have that category. So a ManyToOne relationship.What is the correct way to save this into the database? Do Ia) Create the new Article, save the article to the category asynchronously and redirect to whatever I wantb) Create the new Article, save the article to the category, await the Promise that it has been saved and THEN redirect to whatever I want?I can see that b) makes more sense, but does that not go against the point of node.js's asynchronicity?

Submitted November 26, 2016 at 10:49PM by Netherblood

No comments:

Post a Comment