Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaginateResult #200

Open
mat-twg opened this issue Sep 2, 2023 · 0 comments
Open

PaginateResult #200

mat-twg opened this issue Sep 2, 2023 · 0 comments

Comments

@mat-twg
Copy link

mat-twg commented Sep 2, 2023

Wrong PaginateResult interface or implementation

  interface PaginateResult<T> {
    docs: T[];
    totalDocs: number;
    limit: number;
    hasPrevPage: boolean;
    hasNextPage: boolean;
    page?: number | undefined;
    totalPages: number;
    offset: number;
    prevPage?: number | null | undefined;
    nextPage?: number | null | undefined;
    pagingCounter: number;
    meta?: any;
    [customLabel: string]: T[] | number | boolean | null | undefined;
  }

based on this, it is expected that the offset field is required instead of the page field, as I can judge from the results

// base result out
{
  "docs": [],
  "totalDocs": 0,
  "limit": 10,
  "totalPages": 1,
  "page": 1,
  "pagingCounter": 1,
  "hasPrevPage": false,
  "hasNextPage": false,
  "prevPage": null,
  "nextPage": null
}

you should think about swapping offset and page places, so use interfaces in tests...

  interface PaginateResult<T> {
    page: number | undefined;
    offset?: number;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant