Return first record with offset


#1

I’m trying to get the first record from a model with an offset… this is what I am doing in the route so far to grab this:

var nextContract = this.store.query('contract', {
     limit: 1,
     offset: 25
  });

This seems to be returning all the records in the contract model though. Sometimes the offset will be 28, sometimes it will be 2… who knows. I’m trying to build a “Next” and “Previous” button to view all records in a model. This is the best thing I can think of… (I have an offset query parameter being passed through so for the previous contract, I’m doing offset - 1 and for the next, I’m doing offset + 1.

Any help? Thank you!


#2

Have you tried using a pagination addon like ember-pagination?


#3

Yes I am using that package in a lot of other places on the site, but not here. I am not sure how that would work on this page, but I can try a few things out if you think it will work in this situation. I know their page numbers template shows multiple pages, not just previous and next. I am not sure how to get the links for those two actions from that package.

EDIT: Figured it out by using this package! :slight_smile: Thank you for the suggestion!