Browse Source

Merge pull request #7400 from nocodb/nc-fix/pagination-bugs

Nc fix/pagination bugs
pull/7404/head
Raju Udava 11 months ago committed by GitHub
parent
commit
5cf410599d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      packages/nocodb/src/helpers/PagedResponse.ts
  2. 5
      packages/nocodb/src/schema/swagger.json

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

@ -1,5 +1,6 @@
import { extractLimitAndOffset } from '.';
import type { PaginatedType } from 'nocodb-sdk';
import {NcError} from "~/helpers/catchError";
export class PagedResponseImpl<T> {
constructor(
@ -28,18 +29,19 @@ export class PagedResponseImpl<T> {
this.pageInfo.isFirstPage =
this.pageInfo.isFirstPage ?? this.pageInfo.page === 1;
this.pageInfo.isLastPage =
this.pageInfo.page ===
this.pageInfo.page >=
(Math.ceil(this.pageInfo.totalRows / this.pageInfo.pageSize) || 1);
if (this.pageInfo.page % 1 !== 0) {
this.pageInfo.offset = offset;
delete this.pageInfo.page;
}
}
if (additionalProps) Object.assign(this, additionalProps);
if (offset && offset >= +count) {
this.errors = [
{
message: 'Offset is beyond the total number of records',
},
];
NcError.badRequest('Offset is beyond the total number of records');
}
}

5
packages/nocodb/src/schema/swagger.json

@ -20645,6 +20645,11 @@
"example": 1,
"type": "number"
},
"offset": {
"description": "The current offset and it will be present only when the page is not included",
"example": 1,
"type": "number"
},
"pageSize": {
"description": "The number of pages",
"example": 10,

Loading…
Cancel
Save