Browse Source

fix: apply limit override to PagedResponseImpl

pull/7823/head
mertmit 9 months ago
parent
commit
4de1087d90
  1. 1
      packages/nocodb/src/helpers/PagedResponse.ts
  2. 6
      packages/nocodb/src/helpers/extractLimitAndOffset.ts
  3. 1
      packages/nocodb/src/services/datas.service.ts

1
packages/nocodb/src/helpers/PagedResponse.ts

@ -11,6 +11,7 @@ export class PagedResponseImpl<T> {
count?: number | string; count?: number | string;
l?: number; l?: number;
o?: number; o?: number;
limitOverride?: number;
} = {}, } = {},
additionalProps?: Record<string, any>, additionalProps?: Record<string, any>,
) { ) {

6
packages/nocodb/src/helpers/extractLimitAndOffset.ts

@ -15,6 +15,7 @@ export function extractLimitAndOffset(
offset?: number | string; offset?: number | string;
l?: number | string; l?: number | string;
o?: number | string; o?: number | string;
limitOverride?: number;
} = {}, } = {},
) { ) {
const obj: { const obj: {
@ -40,5 +41,10 @@ export function extractLimitAndOffset(
const offset = +(args.offset || args.o) || 0; const offset = +(args.offset || args.o) || 0;
obj.offset = Math.max(Number.isInteger(offset) ? offset : 0, 0); obj.offset = Math.max(Number.isInteger(offset) ? offset : 0, 0);
// override limit if provided
if (args.limitOverride) {
obj.limit = +args.limitOverride;
}
return obj; return obj;
} }

1
packages/nocodb/src/services/datas.service.ts

@ -210,6 +210,7 @@ export class DatasService {
]); ]);
return new PagedResponseImpl(data, { return new PagedResponseImpl(data, {
...query, ...query,
...(param.limitOverride ? { limitOverride: param.limitOverride } : {}),
count, count,
}); });
} }

Loading…
Cancel
Save