jakubrohleder / angular-jsonapi

Simple and lightweight, yet powerful ORM for your frontend that seamlessly integrates with your JsonAPI server.
http://jakubrohleder.github.io/angular-jsonapi/
GNU General Public License v3.0
96 stars 34 forks source link

Retrieving large data set of relationships #25

Open hedder opened 8 years ago

hedder commented 8 years ago

Quick example:

{ type: "blog", id: "XX", relationships: { posts: [ Array of 10000] } }

Querying such an object from REST-API including 10000 posts could hang the application.

For such a case, it would be great to retrieve posts from a specific api endpoint: /update/XX/posts

Any ideas?

jakubrohleder commented 8 years ago

Yes, you are right. I have not tested the package for such a huge data sets.

If i understand it right you would like to have something like blog object with empty posts relationship and blog.relationships.posts.fetch() method the enables you to get posts from a specific API endpoint (like blogs/XX/posts) preferably with pagination?

Edit: I've found an issue on the discuss.jsonapi.org that is connected to the issue.

hedder commented 8 years ago

Paginating relations is a must have for such a scenario.

But for the library we have to have a way to retrieve them independently from the main object. Basically there're 2 ideas of doing that:

  1. blog.relationships.posts.fetch()
  2. posts.all({url: 'blogs/XX/posts'}) - this way we can specify different url from the main to retrieve them