Map datasource

This commit is contained in:
Adria Navarro 2023-07-21 09:58:58 +02:00
parent e0b91d5941
commit 4c3bfdd8b2
3 changed files with 20 additions and 6 deletions

View File

@ -18,6 +18,8 @@ export const createDataSourceStore = () => {
// Extract table ID
if (dataSource.type === "table" || dataSource.type === "view") {
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

View File

@ -108,13 +108,25 @@ export const deriveStores = context => {
const $filter = get(filter)
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
const newFetch = fetchData({
API,
datasource: {
type: props.datasourceType,
tableId: $tableId,
},
datasource,
options: {
filter: $filter,
sortColumn: $sort.column,

View File

@ -7,7 +7,7 @@ export default class ViewV2Fetch extends DataFetch {
async getDefinition(datasource) {
try {
const { schema } = await this.API.viewV2.getSchema(datasource.tableId)
const { schema } = await this.API.viewV2.getSchema(datasource.id)
return { schema }
} catch (error) {
this.store.update(state => ({
@ -21,7 +21,7 @@ export default class ViewV2Fetch extends DataFetch {
async getData() {
const { datasource } = this.options
try {
const res = await this.API.viewV2.fetch(datasource.tableId)
const res = await this.API.viewV2.fetch(datasource.id)
return { rows: res?.rows || [] }
} catch (error) {
return { rows: [] }