1
0
Fork 0
mirror of synced 2024-08-22 21:41:49 +12:00
budibase/packages/frontend-core/src/fetch/JSONArrayFetch.js
2022-01-20 11:50:18 +00:00

16 lines
565 B
JavaScript

import FieldFetch from "./FieldFetch.js"
import { getJSONArrayDatasourceSchema } from "../utils/json"
export default class JSONArrayFetch extends FieldFetch {
async getDefinition(datasource) {
// JSON arrays need their table definitions fetched.
// We can then extract their schema as a subset of the table schema.
try {
const table = await this.API.fetchTableDefinition(datasource.tableId)
const schema = getJSONArrayDatasourceSchema(table?.schema, datasource)
return { schema }
} catch (error) {
return null
}
}
}