2021-12-17 10:52:12 +01:00
|
|
|
import DataFetch from "./DataFetch.js"
|
2021-12-17 09:22:04 +01:00
|
|
|
import { fetchTableDefinition, fetchViewData } from "api"
|
|
|
|
|
2021-12-17 10:52:12 +01:00
|
|
|
export default class ViewFetch extends DataFetch {
|
2021-12-17 09:22:04 +01:00
|
|
|
static async getSchema(datasource) {
|
|
|
|
if (!datasource?.tableId) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
const table = await fetchTableDefinition(datasource.tableId)
|
|
|
|
return this.enrichSchema(table?.views?.[datasource.name]?.schema)
|
|
|
|
}
|
|
|
|
|
|
|
|
async getData() {
|
|
|
|
const { datasource } = this.options
|
|
|
|
const res = await fetchViewData(datasource)
|
|
|
|
return {
|
|
|
|
rows: res || [],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|