Remove ctx from fetch
This commit is contained in:
parent
81c6eab05e
commit
e7f1bcab9e
|
@ -72,7 +72,7 @@ export async function fetchView(ctx: any) {
|
|||
|
||||
export async function fetch(ctx: any) {
|
||||
const tableId = utils.getTableId(ctx)
|
||||
ctx.body = await quotas.addQuery(() => sdk.rows.fetch(tableId, ctx), {
|
||||
ctx.body = await quotas.addQuery(() => sdk.rows.fetch(tableId), {
|
||||
datasourceId: tableId,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ export async function exportRows(tableId: string, ctx: Ctx) {
|
|||
return pickApi(tableId).exportRows(ctx)
|
||||
}
|
||||
|
||||
export async function fetch(tableId: string, ctx: Ctx) {
|
||||
return pickApi(tableId).fetch(ctx)
|
||||
export async function fetch(tableId: string) {
|
||||
return pickApi(tableId).fetch(tableId)
|
||||
}
|
||||
|
||||
export async function fetchView(tableId: string, ctx: Ctx) {
|
||||
|
|
|
@ -161,8 +161,7 @@ export async function exportRows(ctx: Ctx) {
|
|||
return apiFileReturn(content)
|
||||
}
|
||||
|
||||
export async function fetch(ctx: Ctx) {
|
||||
const tableId = ctx.params.tableId
|
||||
export async function fetch(tableId: string) {
|
||||
return handleRequest(Operation.READ, tableId, {
|
||||
includeSqlRelationships: IncludeRelationship.INCLUDE,
|
||||
})
|
||||
|
@ -172,6 +171,6 @@ export async function fetchView(ctx: Ctx) {
|
|||
// there are no views in external datasources, shouldn't ever be called
|
||||
// for now just fetch
|
||||
const split = ctx.params.viewName.split("all_")
|
||||
ctx.params.tableId = split[1] ? split[1] : split[0]
|
||||
return fetch(ctx)
|
||||
const tableId = split[1] ? split[1] : split[0]
|
||||
return fetch(tableId)
|
||||
}
|
||||
|
|
|
@ -27,12 +27,13 @@ import {
|
|||
import sdk from "../../../../sdk"
|
||||
|
||||
export async function search(ctx: Ctx) {
|
||||
const { tableId } = ctx.params
|
||||
|
||||
// Fetch the whole table when running in cypress, as search doesn't work
|
||||
if (!env.COUCH_DB_URL && env.isCypress()) {
|
||||
return { rows: await fetch(ctx) }
|
||||
return { rows: await fetch(tableId) }
|
||||
}
|
||||
|
||||
const { tableId } = ctx.params
|
||||
const db = context.getAppDB()
|
||||
const { paginate, query, ...params } = ctx.request.body
|
||||
params.version = ctx.version
|
||||
|
@ -121,13 +122,13 @@ export async function exportRows(ctx: Ctx) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function fetch(ctx: Ctx) {
|
||||
export async function fetch(tableId: string) {
|
||||
const db = context.getAppDB()
|
||||
|
||||
const tableId = ctx.params.tableId
|
||||
let table = await db.get(tableId)
|
||||
let rows = await getRawTableData(db, tableId)
|
||||
return outputProcessing(table, rows)
|
||||
const result = await outputProcessing(table, rows)
|
||||
return result
|
||||
}
|
||||
|
||||
async function getRawTableData(db: Database, tableId: string) {
|
||||
|
@ -151,7 +152,7 @@ export async function fetchView(ctx: Ctx) {
|
|||
// if this is a table view being looked for just transfer to that
|
||||
if (viewName.startsWith(DocumentType.TABLE)) {
|
||||
ctx.params.tableId = viewName
|
||||
return fetch(ctx)
|
||||
return fetch(viewName)
|
||||
}
|
||||
|
||||
const db = context.getAppDB()
|
||||
|
|
Loading…
Reference in New Issue