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

Paginate #13

Closed
kvlknctk opened this issue May 16, 2020 · 1 comment
Closed

Paginate #13

kvlknctk opened this issue May 16, 2020 · 1 comment

Comments

@kvlknctk
Copy link

kvlknctk commented May 16, 2020

Hi, thanx for this repo, I have a question. How about paginate. Do you have a bast practice?
I have to set page_number and page count meta.

{ "total": 50, "per_page": 15, "current_page": 1, "last_page": 4, "first_page_url": "http://laravel.app?page=1", "last_page_url": "http://laravel.app?page=4", "next_page_url": "http://laravel.app?page=2", "prev_page_url": null, "path": "http://laravel.app", "from": 1, "to": 15, "data":[ { // Result Object }, { // Result Object } ] }

@hagopj13
Copy link
Owner

hagopj13 commented May 17, 2020

Hi @kvlknctk
Thanks for your suggestion. I just added a mongoose custom plugin that enables pagination.
Have a look at src/services/user.service.js, where I am now using User.paginate(query, options) in the queryUsers function. This is possible through the new custom pagination plugin.
You can of course expand it to include more fields or rename the existing fields by modifying the plugin in src/models/plugins.js .
I will also add some jsdocs explaining how to specify the options.

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