0
votes

How to do pagination in latest version of ember-data (v2.2) and a jsonapi backend? I am in control of the backend implementation so I can implement any strategy, but I would prefer to follow the standard as described here:

http://jsonapi.org/format/#fetching-pagination

However, that description is a bit cryptic to me without an example.

And how to handle that smoothly on the client (ember) side? Is there some built in stuff in ember-data to process the paging-links?

EDIT: I guess to get started I must process the meta information. By overriding the serializer. At the time deserialize is called I can read the meta from the payload but at that time I don't have an object to store it on. Later when my object is done deserialized I don't have access to the payload with the meta information.

Does that make sence? Here is my example payload:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "firstname": "John",
            "lastname": "Doe",
            "email": "[email protected]",
        }
    },
    "included": [{
        "id": "68",
        "type": "activity",
        "attributes": {
            "title": "Yoga",
        }
    }, {
        "id": "65",
        "type": "activity",
        "attributes": {
            "title": "Slalom",
        }
    }],
    "meta": {
        "activity-total": "23",
        "activity-pagesize": "2",
        "activity-offset": "0"
    }
}

Where to put my code that reads the meta information and stores it on the user object?

1

1 Answers

0
votes

You could use the Ember Infinity Addon. It does all the magic for you.