First test passes!
This commit is contained in:
parent
6517150f32
commit
77729737bc
5 changed files with 19 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { IncludeRelationship, Operation, Row } from "@budibase/types"
|
import { IncludeRelationship, Operation } from "@budibase/types"
|
||||||
import { handleRequest } from "../../../api/controllers/row/external"
|
import { handleRequest } from "../../../api/controllers/row/external"
|
||||||
import { breakRowIdField } from "../../../integrations/utils"
|
import { breakRowIdField } from "../../../integrations/utils"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { SearchFilters, SearchParams } from "@budibase/types"
|
import { Row, SearchFilters, SearchParams } from "@budibase/types"
|
||||||
import { isExternalTable } from "../../../integrations/utils"
|
import { isExternalTable } from "../../../integrations/utils"
|
||||||
import * as internal from "./search/internal"
|
import * as internal from "./search/internal"
|
||||||
import * as external from "./search/external"
|
import * as external from "./search/external"
|
||||||
|
@ -45,10 +45,14 @@ export async function exportRows(
|
||||||
return pickApi(options.tableId).exportRows(options)
|
return pickApi(options.tableId).exportRows(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetch(tableId: string) {
|
export async function fetch(tableId: string): Promise<Row[]> {
|
||||||
return pickApi(tableId).fetch(tableId)
|
return pickApi(tableId).fetch(tableId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchRaw(tableId: string): Promise<Row[]> {
|
||||||
|
return pickApi(tableId).fetchRaw(tableId)
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchView(
|
export async function fetchView(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
viewName: string,
|
viewName: string,
|
||||||
|
|
|
@ -186,6 +186,12 @@ export async function fetch(tableId: string): Promise<Row[]> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchRaw(tableId: string): Promise<Row[]> {
|
||||||
|
return await handleRequest<Operation.READ>(Operation.READ, tableId, {
|
||||||
|
includeSqlRelationships: IncludeRelationship.INCLUDE,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchView(viewName: string) {
|
export async function fetchView(viewName: string) {
|
||||||
// there are no views in external datasources, shouldn't ever be called
|
// there are no views in external datasources, shouldn't ever be called
|
||||||
// for now just fetch
|
// for now just fetch
|
||||||
|
|
|
@ -140,14 +140,13 @@ export async function exportRows(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetch(tableId: string): Promise<Row[]> {
|
export async function fetch(tableId: string): Promise<Row[]> {
|
||||||
const db = context.getAppDB()
|
|
||||||
|
|
||||||
const table = await sdk.tables.getTable(tableId)
|
const table = await sdk.tables.getTable(tableId)
|
||||||
const rows = await getRawTableData(db, tableId)
|
const rows = await fetchRaw(tableId)
|
||||||
return await outputProcessing(table, rows)
|
return await outputProcessing(table, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRawTableData(db: Database, tableId: string) {
|
export async function fetchRaw(tableId: string): Promise<Row[]> {
|
||||||
|
const db = context.getAppDB()
|
||||||
let rows
|
let rows
|
||||||
if (tableId === InternalTables.USER_METADATA) {
|
if (tableId === InternalTables.USER_METADATA) {
|
||||||
rows = await sdk.users.fetchMetadata()
|
rows = await sdk.users.fetchMetadata()
|
||||||
|
@ -182,7 +181,7 @@ export async function fetchView(
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const tableId = viewInfo.meta.tableId
|
const tableId = viewInfo.meta.tableId
|
||||||
const data = await getRawTableData(db, tableId)
|
const data = await fetchRaw(tableId)
|
||||||
response = await inMemoryViews.runView(
|
response = await inMemoryViews.runView(
|
||||||
viewInfo,
|
viewInfo,
|
||||||
calculation as string,
|
calculation as string,
|
||||||
|
|
|
@ -28,7 +28,7 @@ export async function migrate(
|
||||||
await migrator.doMigration()
|
await migrator.doMigration()
|
||||||
|
|
||||||
delete table.schema[oldColumn.name]
|
delete table.schema[oldColumn.name]
|
||||||
await sdk.tables.saveTable(table)
|
table = await sdk.tables.saveTable(table)
|
||||||
await updateLinks({ eventType: EventType.TABLE_UPDATED, table, oldTable })
|
await updateLinks({ eventType: EventType.TABLE_UPDATED, table, oldTable })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class UserColumnMigrator implements ColumnMigrator {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async doMigration() {
|
async doMigration() {
|
||||||
let rows = await sdk.rows.fetch(this.table._id!)
|
let rows = await sdk.rows.fetchRaw(this.table._id!)
|
||||||
let rowsById = rows.reduce((acc, row) => {
|
let rowsById = rows.reduce((acc, row) => {
|
||||||
acc[row._id!] = row
|
acc[row._id!] = row
|
||||||
return acc
|
return acc
|
||||||
|
|
Loading…
Reference in a new issue