Using offset parameter in backend request
See original GitHub issueThe app I am working on has two variables for pagination: limit
and offset
. Offset indicates just the starting point from which row the selection in the database table should start, the limit parameter tells how much rows should be selected.
Of course, limit
is equal to the _perPage
and can easily be customized by using the perPageParam
. But offset
is a multiplication of the currentPage
and _perPage
variables.
By using the bound parameters, the request send to the backend can be created:
import InfinityRoute from "ember-infinity/mixins/route";
export default Ember.Route.extend(InfinityRoute, {
perPageParam: 'limit',
offset: Ember.computed('currentPage', '_perPage', function() {
return this.get('currentPage') * this.get('_perPage');
}),
model() {
return this.infinityModel('model-name', {}, { offset: 'offset' });
}
}
As this works nice, I am using the private variable _perPage
. Is there a way to create this request avoiding the use of a private variable?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
offset API parameter - Algolia
Offset is the position in the dataset of a particular record. By specifying offset , you retrieve a subset of records starting with...
Read more >Paging Through Results Using Offset and Limit
To get a different set of items, you can use the offset and limit parameters in the query string of the GET request....
Read more >Offset-based Pagination - Box Developer Documentation
Offset -based pagination is often used where the list of items is of a fixed and predetermined length. Paging. To fetch the first...
Read more >Offset Parameter - REST API Reference
The offset query parameter is used to exclude from a response the first N items of a resource collection. For example, to show...
Read more >How can I use Python requests to paginate api calls with offset ...
The offset parameter controls the starting point within the collection of resource results. If you have a collection of 15 items to be ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Now that the route mixin is deprecated you can do this by extending InfinityModel.
@jevanlingen - _perPage is set by the initial model invocation, and is private for that reason. Ember Infinity assumes that
perPage
is not dynamic - by making it public we’re likely to run into some wacky problems for some users. I’d rather leave it private and let the savvy use it when they know what they’re doing.