Get first 20 records

Options

Hi, I'm looking to achieve the following scenario.

I currently have a database call that gets all records, and includes pagination (this shows 28 records per page)

If the user is not on a premium plan, however, I only want them to be able to see 20 items maximum. How can I limit the amount of items that I retrieve from the database to 20?

Answers

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Hi, Jack. Following our education on RBAC (video here), you can modify this approach to change the query based on what the user is returned via external paging.

    External paging allows you to specify paging details from a variable or an input. So, once you grab the user record and determine their role (or extract it from the auth token, whichever method you choose is valid), you can use a conditional if/then statement to set the page and per_page values before running the query.