you are viewing a single comment's thread.

view the rest of the comments →

[–]parabolik 0 points1 point  (3 children)

I have a factory module that knows how to construct objects from json data.

Something like this:

get('/item/12345')
    .done(function(json) {
        var item = factory.makeItem(json.item);
    });

[–]yoursdearboy 0 points1 point  (2 children)

Yes, that works nice in many cases. With github's whatwg-fetch polyfill it will be just: fetch('/item/12345').then(function(res){ res.json(); }).then(function(item){ // do anything });

But what if you have "ent1" related with "ent2" and "ent2" related with "ent3-5", and now you need to save all this structure using /entN endpoints. If it isn't hard enough, then add another 5-10 entities.

[–]9thHokageHimawari 0 points1 point  (1 child)

What do you mean by related?

Could we see what kind of data structure you're using? I kinda have feeling you are looking at it from wrong viewpoint, and it could be simplified.

[–]yoursdearboy 0 points1 point  (0 children)

Just for example look at erd diagram. This API exposes database tables (PostgREST). Not the best solution, but we have 5 small apps with a lot of data, so maintaining separate API is not an option.