2023-07-19 10:16:12 +02:00
|
|
|
import DataFetch from "./DataFetch.js"
|
|
|
|
|
|
|
|
export default class ViewV2Fetch extends DataFetch {
|
|
|
|
async getSchema(datasource, definition) {
|
|
|
|
return definition.schema
|
|
|
|
}
|
|
|
|
|
|
|
|
async getDefinition(datasource) {
|
|
|
|
try {
|
2023-07-20 09:46:27 +02:00
|
|
|
const { schema } = await this.API.viewV2.getSchema(datasource.tableId)
|
|
|
|
return { schema }
|
2023-07-19 10:16:12 +02:00
|
|
|
} catch (error) {
|
|
|
|
this.store.update(state => ({
|
|
|
|
...state,
|
|
|
|
error,
|
|
|
|
}))
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async getData() {
|
|
|
|
const { datasource } = this.options
|
|
|
|
try {
|
2023-07-19 22:57:54 +02:00
|
|
|
const res = await this.API.viewV2.fetch(datasource.tableId)
|
2023-07-19 10:16:12 +02:00
|
|
|
return { rows: res?.rows || [] }
|
|
|
|
} catch (error) {
|
|
|
|
return { rows: [] }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|