Return full object from search

This commit is contained in:
Adria Navarro 2023-07-24 10:05:27 +02:00
parent 9cf401162b
commit 1cf4e6e85a
2 changed files with 6 additions and 6 deletions

View File

@ -155,7 +155,7 @@ export async function searchView(ctx: Ctx<void, SearchResponse>) {
} }
ctx.status = 200 ctx.status = 200
const { rows } = await quotas.addQuery( ctx.body = await quotas.addQuery(
() => () =>
sdk.rows.search({ sdk.rows.search({
tableId: view.tableId, tableId: view.tableId,
@ -169,8 +169,6 @@ export async function searchView(ctx: Ctx<void, SearchResponse>) {
datasourceId: view.tableId, datasourceId: view.tableId,
} }
) )
ctx.body = { rows }
} }
export async function validate(ctx: Ctx) { export async function validate(ctx: Ctx) {

View File

@ -34,13 +34,15 @@ function pickApi(tableId: any) {
export async function search(options: SearchParams): Promise<{ export async function search(options: SearchParams): Promise<{
rows: any[] rows: any[]
hasNextPage?: boolean
bookmark?: number | null
}> { }> {
let { rows } = await pickApi(options.tableId).search(options) const result = await pickApi(options.tableId).search(options)
if (options.fields) { if (options.fields) {
rows = rows.map((r: any) => _.pick(r, options.fields!)) result.rows = result.rows.map((r: any) => _.pick(r, options.fields!))
} }
return { rows } return result
} }
export interface ExportRowsParams { export interface ExportRowsParams {