Saturday 7 October 2017

Routes configuration for update

Hi, I have actually a basic authentication system. I work with node and mongodb. I have a collection "users":User - email: string - password: string Ok, at this point, I have actually two routes: register (users/register) and login (users/login), and all is working fine.Now I want to add a field to the user, an array of Cars:User - email: string - password: string - cars: Car[] From my frontend (angular 2), a user will be able to add, update and remove a Car.I see two options to do this:I add only one route to update the user (users/update). It means I will have to send in the parameters of the request the new value of Collection[] (and others future editable fields).Or I create three new routes (users/collections/add, users/collections/update and users/collections/delete). In this case, I will only have to send the parameters requested to add, update, or delete a collection.I don't know which one to use. The first one seems more code saver for both side (node and angular 2), but more messy than the second one. The second one needs more code, but it will be maybe easier to use and maintain once coded.Do you have any advice?

Submitted October 07, 2017 at 07:23PM by GreenMonkeyBoy

No comments:

Post a Comment