Original post

So Im taking a crack at my first solo app, and I'm trying to keep it (relatively) simple.

Basically, the end stage is to build a web app (and later a phone app) that uses REST API functions to pass a JSON body into a Struct to search, add, update, or delete rows in a database.

The rows will all have a quantity assigned to them. When I'm updating a row, I want it to also delete it if the quantity becomes less than one. Potentially, I might also want to add a row if I try and update it but no rows are affected. This would mean that I would just need to change the quantity that is passed into the JSON body and the single function would take care of the rest, adding, updating and deleting as necessary.

For best practice sake, is it better to make all these functions separately and then call them accordingly? I'm assuming I would need to make some sort of helper function to actually delete the rows since I wouldn't want to call a REST function within another REST function. Alternatively, is it okay to consolidate these functions into one that responds more dynamically? It would mean less tinkering with the JS on the frontend (which is where I'm weakest right now anyway).

Any tips for how best to organize this would be appreciated!

submitted by /u/whatacad
[link] [comments]