Browse Source

fix: PagedResponseImpl handle aliases

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2637/head
mertmit 2 years ago
parent
commit
0f15d18a38
  1. 20
      packages/nocodb/src/lib/meta/helpers/PagedResponse.ts

20
packages/nocodb/src/lib/meta/helpers/PagedResponse.ts

@ -1,14 +1,24 @@
import { PaginatedType } from 'nocodb-sdk'; import { PaginatedType } from 'nocodb-sdk';
const config: any = {
limitDefault: Math.max(+process.env.DB_QUERY_LIMIT_DEFAULT || 25, 1),
limitMin: Math.max(+process.env.DB_QUERY_LIMIT_MIN || 1, 1),
limitMax: Math.max(+process.env.DB_QUERY_LIMIT_MAX || 1000, 1),
};
export class PagedResponseImpl<T> { export class PagedResponseImpl<T> {
constructor( constructor(
list: T[], list: T[],
{ args: { limit?: number; offset?: number; count?: number, l?: number, o?: number } = {}
limit = 25,
offset = 0,
count = null,
}: { limit?: number; offset?: number; count?: number } = {}
) { ) {
const limit = Math.max(
Math.min(
args.limit || args.l || config.limitDefault,
config.limitMax
),
config.limitMin
);
const offset = Math.max(+(args.offset || args.o) || 0, 0);
const count = args.count || null;
this.list = list; this.list = list;
if (count !== null) { if (count !== null) {
this.pageInfo = { totalRows: +count }; this.pageInfo = { totalRows: +count };

Loading…
Cancel
Save