ajax - Node/Express - one route/complex route code? or multiple-routes/simple route code? -
How to do the CRUD and see the best practice guideline on having a synchronized browser-code model with DB. The context is an Angular / Express App and Postgres DB.
I have a UI editing form that currently shows data records stored in DB, can implement, submit, and express updates to user postgres. After the update, I perform an edited operation to pull the data record again so that my client-side model is synchronized with DB data.
So there are two DB visits, updates and read here. My question is, is it better practice for 1? Keep your expressway code ultra-simple and keep two Ajaxes from the browser (AJAX on the form, after the success response, another AJAX to read the data again from DB), or 2) do a single Ajax on the form and express Update the route, then read, then return the data to the browser?
Comments
Post a Comment