question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No paginate method on my Model class

See original GitHub issue

I must be doing something wrong because I don’t have a .paginate() method on my Models. The following test case demonstrates the problem:

var mongoose = require('mongoose')
  , paginate = require('mongoose-paginate');

var BlogSchema = new mongoose.Schema({
  id    : mongoose.Schema.ObjectId,
  title : String,
  entry : String,
  date  : Date
});

var BlogEntry = mongoose.model('BlogEntry', BlogSchema);
console.log(BlogEntry.paginate); //=> outputs undefined

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
drewhamlettcommented, Mar 9, 2014

Here you guys go.

Options is just something that you are searching by. Like

var options = {
  code: 'KRDU'
}
var perPage = 10;
var page = 1;
var findAirports = function (next) {
        Airport
            .find(options)
            .select('name code city state')
            .limit(perPage)
            .skip((perPage * page) - perPage)
            .sort(sorting)
            .exec(next);
    };

    var countAirports = function (next) {
        Airport.count(options).exec(next);
    };

    async.parallel({
        find: findAirports,
        count: countAirports
    }, function done(err, results) {

        return res.json({
            total: results.count,
            data: results.find
        });
    });

0reactions
ekumahostcommented, Jan 16, 2022

no solutions work. its been years here no perfect result

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel Method paginate does not exist - Stack Overflow
I need to get all records where users id equals current authenticated users id. Works well without paginate() method. laravel · methods ......
Read more >
Pagination - Django documentation
Under the hood, all methods of pagination use the Paginator class. It does all the heavy lifting of actually splitting a QuerySet into...
Read more >
Database: Pagination - The PHP Framework For Web Artisans
The paginate method counts the total number of records matched by the query before retrieving the records from the database. This is done...
Read more >
Class PaginatorComponent | CakePHP 2.9
This component is used to handle automatic model data pagination. The primary way to use this component is to call the paginate() method....
Read more >
Collection::paginate does not exist - Laracasts
@shimana NO, you are still doing $liking = $this->user->liking(Post::class)->where('status',5)->get() which gets every record from the database. You then ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found