I’m finally getting into ember data and the json-api standard. I’d say I have a rudimentary understanding of them (stay tuned for just how rudimentary)…
I am having a hard time figuring out why you’d want to handle data relationships on the client side.
Let’s say I want to load a category, and that category has 112 products in it. I understand how the ‘category’ and ‘products’ models are set up, but when this is loaded, it’s going to trigger 113 xhr’s. OK, I can limit it to 16 or 32 per page, but still we’re talking about alot of xhr’s. Then you add in any assets (like images) that each rendered product needs, you double the number of http requests. I guess I don’t really see the advantage of that method, over the “traditional” method of having the server put everything together in a single payload. Unless…I am completely misunderstanding something!
Also, let’s say you need to do some complex sorting like “these 8 items need to always appear first for category x”, or “make any backordered items appear further down in the results”. Or even, heck, “sort by price”. With my traditional SQL approach, I’d build as much of this logic right into my queries as possible, to reduce the amount of application code. Then you can run the same query again with LIMIT and voila, you can page thru a highly customized dataset.
How would that work with ember-data and the simple relationships? I am guessing you’d need to load in the entire result set (112 xhr’s?) and THEN run it through the sort function, and some kind of pagination function.
I’m SURE solutions exist to these questions (or explanations that dispel my naive ideas!), but I am having a hard time digging them up. The tutorials I’ve found are great, but are simplistic intros (as they should be). I am pretty sure ember-data is a great tool, but having a hard time getting my head around it! I think I’m actually at a disadvantage here because of years of “traditional” web development. Any help appreciated!