RE: relate a Collection and a PagedCollection

On Sunday, April 27, 2014 6:29 PM, Ruben Verborgh wrote:
> My issue with Hydra's list (collection) of pages
> is that you cannot point to the list and the page separately.

Yeah, that's the main issue and we should really do something about it. I
have been tinkering with various design over the last couple of days. None
of them made me completely happy yet. What I quite like about the current
design is that you can "upgrade" a collection into a paged collection
without changing the link to the collection:

  /x --[property]--> /collection

  /collection a Collection
         member ....

and then, at some point when /collection grows too big, you just add a
nextPage link:

  /collection a Collection
         member ....
         nextPage /collection?page=2

 (but as we already discussed, it may be unclear what is meant in that case,
i.e., just the first page or all pages)

Your proposal was to model this as Collections (with and without members)
and Pages (always with members). That means that you always have to handle
two cases. Perhaps it would be simpler to turn *all* Collections into,
what's currently called, PagedCollections. Some of these PagedCollections
then just happen to consist of just a single "page". One design that I've
tried was to rename PagedCollection to PartialCollection and move all the
paging information to a separate entity. Something like

   /collection a PartialCollection
      member ...
      paging [
        totalItems ...
        itemsPerPage ...
        nextPage ...
        ...
      ]

But that still doesn't resolve the issue that we can't point to the complete
collection and individual PartialCollections separately. One thing we could
of course do is to just acknowledge that in the spec and say that pointing
to a PartialCollection (from something else than the pagination links) is
equivalent to transforming all interlinked PartialCollections to a single
Collection referencing all members and pointing to it.

Perhaps you, or someone else, has some other, better ideas.



--
Markus Lanthaler
@markuslanthaler

Received on Thursday, 1 May 2014 20:50:23 UTC