Uhm... it seem the `paginate()` method apply to the model, not the schema:
var mongoose = require('mongoose'),
mongoosePaginate = require('mongoose-paginate'),
db = mongoose.connection;
/*********************************************************************************/
/* Connect to DB */
/*********************************************************************************/
mongoose.connect('mongodb://localhost/mpaginate');
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);
var User = mongoose.model('users', userSchema);
var u = new User({
firstName: "p",
lastName: "p",
userName: "p",
password: "p"
});
u.save();
User.paginate({}, { page: 1, limit: 1 }, function(err, results,
pageCount, itemCount) {
if(err){
console.log("error");
console.log(err);
} else {
console.log(results);
}
});
});
This chunck is working on my local
--
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/CAJYqLYOApjTw8c4JL2t3LjDyM5XQsyeyajbFSAyHaC1qTp2uhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.