Fetch viewV2
This commit is contained in:
parent
37aed2d171
commit
a9cb838847
|
@ -0,0 +1,33 @@
|
||||||
|
import DataFetch from "./DataFetch.js"
|
||||||
|
|
||||||
|
export default class ViewV2Fetch extends DataFetch {
|
||||||
|
async getSchema(datasource, definition) {
|
||||||
|
return definition.schema
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDefinition(datasource) {
|
||||||
|
try {
|
||||||
|
const viewResponse = await this.API.viewV2.get(datasource.tableId)
|
||||||
|
const result = await this.API.fetchTableDefinition(
|
||||||
|
viewResponse.data.tableId
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
} catch (error) {
|
||||||
|
this.store.update(state => ({
|
||||||
|
...state,
|
||||||
|
error,
|
||||||
|
}))
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getData() {
|
||||||
|
const { datasource } = this.options
|
||||||
|
try {
|
||||||
|
const res = await this.API.viewV2.fetch(datasource.tableId)
|
||||||
|
return { rows: res?.rows || [] }
|
||||||
|
} catch (error) {
|
||||||
|
return { rows: [] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import TableFetch from "./TableFetch.js"
|
import TableFetch from "./TableFetch.js"
|
||||||
import ViewFetch from "./ViewFetch.js"
|
import ViewFetch from "./ViewFetch.js"
|
||||||
|
import ViewV2Fetch from "./ViewV2Fetch.js"
|
||||||
import QueryFetch from "./QueryFetch.js"
|
import QueryFetch from "./QueryFetch.js"
|
||||||
import RelationshipFetch from "./RelationshipFetch.js"
|
import RelationshipFetch from "./RelationshipFetch.js"
|
||||||
import NestedProviderFetch from "./NestedProviderFetch.js"
|
import NestedProviderFetch from "./NestedProviderFetch.js"
|
||||||
|
@ -11,6 +12,7 @@ import GroupUserFetch from "./GroupUserFetch.js"
|
||||||
const DataFetchMap = {
|
const DataFetchMap = {
|
||||||
table: TableFetch,
|
table: TableFetch,
|
||||||
view: ViewFetch,
|
view: ViewFetch,
|
||||||
|
viewV2: ViewV2Fetch,
|
||||||
query: QueryFetch,
|
query: QueryFetch,
|
||||||
link: RelationshipFetch,
|
link: RelationshipFetch,
|
||||||
user: UserFetch,
|
user: UserFetch,
|
||||||
|
|
Loading…
Reference in New Issue