Map datasource
This commit is contained in:
parent
e0b91d5941
commit
4c3bfdd8b2
|
@ -18,6 +18,8 @@ export const createDataSourceStore = () => {
|
||||||
// Extract table ID
|
// Extract table ID
|
||||||
if (dataSource.type === "table" || dataSource.type === "view") {
|
if (dataSource.type === "table" || dataSource.type === "view") {
|
||||||
dataSourceId = dataSource.tableId
|
dataSourceId = dataSource.tableId
|
||||||
|
} else if (dataSource.type === "viewV2") {
|
||||||
|
dataSourceId = dataSource.id
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only one side of the relationship is required as a trigger, as it will
|
// Only one side of the relationship is required as a trigger, as it will
|
||||||
|
|
|
@ -108,13 +108,25 @@ export const deriveStores = context => {
|
||||||
const $filter = get(filter)
|
const $filter = get(filter)
|
||||||
const $sort = get(sort)
|
const $sort = get(sort)
|
||||||
|
|
||||||
|
let datasource
|
||||||
|
if (props.datasourceType === "viewV2") {
|
||||||
|
const tableId = $tableId
|
||||||
|
datasource = {
|
||||||
|
type: props.datasourceType,
|
||||||
|
id: $tableId,
|
||||||
|
tableId: tableId.split("_").slice(0, -1).join("_"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
datasource = {
|
||||||
|
type: props.datasourceType,
|
||||||
|
tableId: $tableId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create new fetch model
|
// Create new fetch model
|
||||||
const newFetch = fetchData({
|
const newFetch = fetchData({
|
||||||
API,
|
API,
|
||||||
datasource: {
|
datasource,
|
||||||
type: props.datasourceType,
|
|
||||||
tableId: $tableId,
|
|
||||||
},
|
|
||||||
options: {
|
options: {
|
||||||
filter: $filter,
|
filter: $filter,
|
||||||
sortColumn: $sort.column,
|
sortColumn: $sort.column,
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default class ViewV2Fetch extends DataFetch {
|
||||||
|
|
||||||
async getDefinition(datasource) {
|
async getDefinition(datasource) {
|
||||||
try {
|
try {
|
||||||
const { schema } = await this.API.viewV2.getSchema(datasource.tableId)
|
const { schema } = await this.API.viewV2.getSchema(datasource.id)
|
||||||
return { schema }
|
return { schema }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.store.update(state => ({
|
this.store.update(state => ({
|
||||||
|
@ -21,7 +21,7 @@ export default class ViewV2Fetch extends DataFetch {
|
||||||
async getData() {
|
async getData() {
|
||||||
const { datasource } = this.options
|
const { datasource } = this.options
|
||||||
try {
|
try {
|
||||||
const res = await this.API.viewV2.fetch(datasource.tableId)
|
const res = await this.API.viewV2.fetch(datasource.id)
|
||||||
return { rows: res?.rows || [] }
|
return { rows: res?.rows || [] }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { rows: [] }
|
return { rows: [] }
|
||||||
|
|
Loading…
Reference in New Issue