2020-11-12 10:07:09 +01:00
|
|
|
import api from "./api"
|
2020-11-12 13:24:45 +01:00
|
|
|
import { enrichRows } from "./rows"
|
2020-11-12 10:07:09 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches a table definition.
|
|
|
|
* Since definitions cannot change at runtime, the result is cached.
|
|
|
|
*/
|
|
|
|
export const fetchTableDefinition = async tableId => {
|
|
|
|
return await api.get({ url: `/api/tables/${tableId}`, cache: true })
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches all rows from a table.
|
|
|
|
*/
|
2020-11-12 13:24:45 +01:00
|
|
|
export const fetchTableData = async tableId => {
|
|
|
|
const rows = await api.get({ url: `/api/${tableId}/rows` })
|
|
|
|
return await enrichRows(rows, tableId)
|
2020-11-12 10:07:09 +01:00
|
|
|
}
|