Skip to main content

Use "skipRecords" and "maxRecords" to return top N results

Using the "skipRecords" and "maxRecords" properties is the best way to return the top N records from the "getRecordsByTable", "getRecordsByIndex", "getRecordsByPartialKeyRange", "getRecordsInKeyRange", and "getRecordsStartingAtKey" actions.

This procedure returns the top two records from the "athlete" table.

Important

It is possible to use the "skipRecords" and "maxRecords" properties to paginate data, but a cursor is better. An issue with "skipRecords" is that it causes the server to walk records from the beginning until it has skipped the requested number of records. Skipping over records is slow.

In contrast, a cursor remembers its last position and instantly returns the next set of records. Use the "returnCursor": true property to return a cursor to paginate quickly and efficiently.

  1. Paste this code into the API Request editor.

    {
        "action": "getRecordsByTable",
        "params": {
            "tableName": "athlete",
            "skipRecords": 0,
            "maxRecords": 2
        },
        "authToken": "clickApplyDefaultsToReplaceThisWithValidAuthToken"
    }
    
  2. Click Apply defaults to JSON request (Apply) to set the "authToken" to a valid value.

  3. Click Send request (Run Icon).

  4. Verify the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.