Add limit on request
This commit is contained in:
parent
4f08f900ed
commit
250505a19b
|
@ -39,6 +39,7 @@ export async function searchView(
|
||||||
query: view.query || {},
|
query: view.query || {},
|
||||||
fields: viewFields,
|
fields: viewFields,
|
||||||
...getSortOptions(ctx.request.body, view),
|
...getSortOptions(ctx.request.body, view),
|
||||||
|
limit: ctx.request.body.limit,
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), {
|
const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), {
|
||||||
|
|
|
@ -1263,6 +1263,22 @@ describe("/rows", () => {
|
||||||
|
|
||||||
expect(response.body.rows).toHaveLength(0)
|
expect(response.body.rows).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("returns table rows from view", async () => {
|
||||||
|
const table = await config.createTable(userTable())
|
||||||
|
const rows = []
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
rows.push(await config.createRow({ tableId: table._id }))
|
||||||
|
}
|
||||||
|
const limit = generator.integer({ min: 1, max: 8 })
|
||||||
|
|
||||||
|
const createViewResponse = await config.api.viewV2.create()
|
||||||
|
const response = await config.api.viewV2.search(createViewResponse.id, {
|
||||||
|
limit,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.body.rows).toHaveLength(limit)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ export interface PatchRowResponse extends Row {}
|
||||||
export interface SearchRowRequest extends Omit<SearchParams, "tableId"> {}
|
export interface SearchRowRequest extends Omit<SearchParams, "tableId"> {}
|
||||||
|
|
||||||
export interface SearchViewRowRequest
|
export interface SearchViewRowRequest
|
||||||
extends Pick<SearchRowRequest, "sort" | "sortOrder" | "sortType"> {}
|
extends Pick<SearchRowRequest, "sort" | "sortOrder" | "sortType" | "limit"> {}
|
||||||
|
|
||||||
export interface SearchRowResponse {
|
export interface SearchRowResponse {
|
||||||
rows: any[]
|
rows: any[]
|
||||||
|
|
Loading…
Reference in New Issue