This renders a table with selectable rows. The function resolves with the user-selected rows.
const rows = await io.input.table(
'Users', // { offset } is automatically calulated.
async ({ offset, pageSize }) => { // This function is fired every time the user navigates table pages.
const { count } = (await db.select({ count: count() }).from(employeesTable))[0]
return {
totalResults: count,
resultsToDisplay: await db
.select(employeesTable)
.fields('*') // Or specify specific fields if needed
.limit(pageSize)
.offset(offset)
}
},
)
console.log(rows)
The label to render above the input.
An asynchronous function that receives { query: string, page: number, offset: number, pageSize: number }
as input and outputs the resulting rows to display and a count of total results.
Represents the query entered by the user.
Represents the page the user is on.
Represents the automatically calculated item offset. This calculation is based on page size and the total number of records.
const offset = (page - 1) * pageSize
Represents the amount of items to render on each page.
Inherited from the options.resultsPerPage
parameter.
The number of rows to render on each page. Default 100
.
Default value rendered in input. Default []
.
The placeholder to display in the query input field. Default undefined
.
Render a search bar to filter rows. Default true
.
The columns
parameter is used to map specific column names and behaviors. Default undefined
.
An asynchronous function that takes unknown
input and outputs either true
or an error message string
to show the user.