1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00

Add limit on request

This commit is contained in:
Adria Navarro 2023-08-04 18:41:49 +03:00
parent 4f08f900ed
commit 250505a19b
3 changed files with 18 additions and 1 deletions

View file

@ -39,6 +39,7 @@ export async function searchView(
query: view.query || {},
fields: viewFields,
...getSortOptions(ctx.request.body, view),
limit: ctx.request.body.limit,
}
const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), {

View file

@ -1263,6 +1263,22 @@ describe("/rows", () => {
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)
})
})
})
})

View file

@ -12,7 +12,7 @@ export interface PatchRowResponse extends Row {}
export interface SearchRowRequest extends Omit<SearchParams, "tableId"> {}
export interface SearchViewRowRequest
extends Pick<SearchRowRequest, "sort" | "sortOrder" | "sortType"> {}
extends Pick<SearchRowRequest, "sort" | "sortOrder" | "sortType" | "limit"> {}
export interface SearchRowResponse {
rows: any[]