Convert ViewFetch

This commit is contained in:
Adria Navarro 2025-01-02 16:25:37 +01:00
parent 69ad15f79c
commit b420fda524
1 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,25 @@
import { Table, View } from "@budibase/types"
import DataFetch from "./DataFetch.js"
export default class ViewFetch extends DataFetch {
getSchema(datasource, definition) {
type ViewV1 = View & { name: string }
export default class ViewFetch extends DataFetch<ViewV1, Table> {
async getDefinition(datasource: ViewV1) {
if (!datasource?.tableId) {
return null
}
try {
return await this.API.fetchTableDefinition(datasource.tableId)
} catch (error: any) {
this.store.update(state => ({
...state,
error,
}))
return null
}
}
getSchema(datasource: ViewV1, definition: Table) {
return definition?.views?.[datasource.name]?.schema
}