We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I'm currently working on getting this package working and I believe I have it implemented correctly.
I have the following:
route
router.get('/dashboard', ensureAuthenticated, (req, res) => { User.paginate({}, { page: 1, limit: 6 }, function(err, result) { result.limit - 6 result.page - 1 }); User.find({}, function(err, users) { res.render('dashboard/index.hbs', { pageTitle: 'Dashboard', users: users }); }); });
and I have implemented the package in the user.js and called UserSchema.plugin(mongoosePaginate);.
user.js
UserSchema.plugin(mongoosePaginate);
However I am unsure on how to get a visible implementation of this working so it is clickable through the pages.
I am using Bootstrap 3 and the mustache templating engine.
The text was updated successfully, but these errors were encountered:
I can give you a short idea of what I am using:
In My Route:
router.get('/users', (req, res)=>{ User.paginate({}, { sort: {'_createdAt': -1}, limit: req.query.l ? parseInt(req.query.l) : 12, page: req.query.page ? req.query.page : 1 }) .then((result)=>{ //result is a returned array from the database pagination return res.render('admin/dashboard', { title: "Dashboard | Admin Panel", users: result.docs, total: result.total, currentPage: result.page, limit: result.limit }); }) .catch((err)=>{ console.log(err); return res.send('Error Contacting the database or Some Trouble happened while exec Pagination Script'); }) })
In My .pug file (using Bootstrap 4 theme):
.pug
- var PossiblePages = Math.trunc(total/limit)+1; - var nextPage = currentPage nav(aria-label="...") ul.pagination.pagination-md.justify-content-center li.page-item(class= {disabled: currentPage==1}) a.page-link(href="/admin/dashboard?page="+(currentPage-1) tabindex="-1") Previous - var p = 1; while p <= PossiblePages li.page-item(class= {active: currentPage == p} ) a.page-link(href="/admin/dashboard?page="+p)=p - p++; li.page-item(class={disabled: currentPage == PossiblePages}) a.page-link(href="/admin/dashboard?page="+ ++nextPage ) Next
As you can see, I am making use of req.query or ?p=2 (for ex) for getting mine work.
req.query
?p=2
Sorry, something went wrong.
No branches or pull requests
Hi,
I'm currently working on getting this package working and I believe I have it implemented correctly.
I have the following:
route
and I have implemented the package in the
user.js
and calledUserSchema.plugin(mongoosePaginate);
.However I am unsure on how to get a visible implementation of this working so it is clickable through the pages.
I am using Bootstrap 3 and the mustache templating engine.
The text was updated successfully, but these errors were encountered: