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

TypeError: t.count is not a function #2

Open
GarryOne opened this issue Oct 5, 2022 · 1 comment
Open

TypeError: t.count is not a function #2

GarryOne opened this issue Oct 5, 2022 · 1 comment

Comments

@GarryOne
Copy link

GarryOne commented Oct 5, 2022

Error

TypeError: t.count is not a function
    at /Users/mac/www/cysiam/CYSIAM-api/node_modules/prisma-pagination/dist/index.js:1:492
    at ClientService.findAll (/Users/mac/www/cysiam/CYSIAM-api/dist/src/modules/client/client.service.js:31:16)
    at ClientController.getAllClients (/Users/mac/www/cysiam/CYSIAM-api/dist/src/modules/client/client.controller.js:25:35)
    at /Users/mac/www/cysiam/CYSIAM-api/node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at async /Users/mac/www/cysiam/CYSIAM-api/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at async /Users/mac/www/cysiam/CYSIAM-api/node_modules/@nestjs/core/router/router-proxy.js:9:17

My usage example:

const paginate = createPaginator({ perPage: 5 });

    return paginate<any, any>(
      this.prisma.clients.findMany({
        skip,
        take,
        where,
        orderBy,
      }),
    );

Versions:
Node: 16.10.0
Prisma: 4.4.0
prisma-pagionation: 0.2.3

@smohammadhn
Copy link

You provided the entire prisma findMany method to The paginate function arguments. which is incorrect.

The paginate function takes three arguments.

first: only the model. (this.prisma.clients)
second: findMany options. (only one object containing all the options except skip & take) ({ where, orderBy })
third: The pagination option which are ({ perPage: 10, page: 1})

const paginate = createPaginator();

return paginate<any, any>(
  this.prisma.clients,
  { where, orderBy },
  { page: 1, perPage: 5 }
);

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

2 participants