1
0
Fork 0
mirror of synced 2024-09-19 02:39:37 +12:00
budibase/packages/frontend-core/src/api/tables.js

51 lines
930 B
JavaScript

export const buildTableEndpoints = API => ({
/**
* Fetches a table definition.
* Since definitions cannot change at runtime, the result is cached.
*/
fetchTableDefinition: async tableId => {
return await API.get({
url: `/api/tables/${tableId}`,
cache: true,
})
},
/**
* Fetches all rows from a table.
*/
fetchTableData: async tableId => {
return await API.get({ url: `/api/${tableId}/rows` })
},
/**
* Searches a table using Lucene.
*/
searchTable: async ({
tableId,
query,
bookmark,
limit,
sort,
sortOrder,
sortType,
paginate,
}) => {
if (!tableId || !query) {
return {
rows: [],
}
}
return await API.post({
url: `/api/${tableId}/search`,
body: {
query,
bookmark,
limit,
sort,
sortOrder,
sortType,
paginate,
},
})
},
})