I'm trying to use the mongoose-paginate plugin: 
https://www.npmjs.com/package/mongoose-paginate

This is my code, but I'm getting an error: undefined is not a function
 
    var mongoose = require('mongoose'),
        mongoosePaginate = require('mongoose-paginate'),
        db = mongoose.connection;


/*********************************************************************************/
/* Connect to DB */
/*********************************************************************************/

mongoose.connect('mongodb://localhost/users');

db.on('error', console.error.bind(console, 'Connection error:'));
db.once('open', function (callback) {
    console.log('Connected to MongoDB!');
    var userSchema = mongoose.Schema({
        firstName: String,
        lastName: String,
        userName: String,
        password: String
    });
    
    
    userSchema.plugin(mongoosePaginate);

    userSchema.paginate({}, { // this is what's causing the error
        page: 2, limit: 1
    }, function(err, results, pageCount, itemCount) {
    console.log(results);
    });

});

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/707b93b2-c085-4957-870c-7ec8ccc3751b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to