Custom queries
By default, Kottster manages data fetching internally. You can also define custom fetching logic, such as using raw SQL or extracting data from an external resource.
To do this, pass a select
object with an executeQuery
function to createTableRpc:
executeQuery
Arguments:
An object with the following optional properties:
page
(number
, optional): The current page number, passed if pagination is enabled.search
(string
, optional): A search term, passed if search is enabled.
Return value:
An object with the following properties:
records
(array
): An array of records to display in the table.totalRecords
(number
, optional): The total number of records. Providing this enables pagination.
Example with a raw SQL query
This example demonstrates how to use a raw SQL query with Knex to fetch data.
Example with pagination
This example demonstrates how to use a raw SQL query with Knex to fetch data while supporting pagination:
Last updated