Reputation: 38583
I am using ember-data.
I have a search screen that lazy loads data using ember.infinitescroll
. I need to display the total number of records returned (which I can only find out by doing a server call as I don't have all records loaded locally)
The result will be something like this (the format can change as necessary)
{
"totalRecords" : 552
}
This is not really a model, what is the best way of achieving this?
Upvotes: 0
Views: 36
Reputation: 3594
You want to use meta
in your API response. Ember data is aware of this
HTTP API Response
{
posts: [ ... ]
meta: {
page: 5,
totalPages: 70,
totalRecords: 700
}
}
Ember code would be:
result = this.store.find('post', { page: 5 });
totalRecords = result.get("content.meta.totalRecords");
See more here: http://emberjs.com/guides/models/handling-metadata/
Upvotes: 1