Use "skipRecords"
and "maxRecords"
to return top N results
Complete the tutorial setup.
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.
Paste this code into the API Request editor.
{ "action": "getRecordsByTable", "params": { "tableName": "athlete", "skipRecords": 0, "maxRecords": 2 }, "authToken": "clickApplyDefaultsToReplaceThisWithValidAuthToken" }
Click Apply defaults to JSON request () to set the
"authToken"
to a valid value.Click Send request ().
Verify the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.