I'm trying to make an easy pagination for a REST service with MongoDB and Mongoose. Here's how I'm doin it right now.
As you can see I'm sending 0 on 'next' variable, but I just want to send zero when there are no more results. How could I get when results are over and there are no more to get?
var user = User.find(
{},
{},
{skip: skip, limit: limit},
function(err, docs) {
if (!err) {
res.json({users: docs, next: 0} );
} else {
throw err;
}
});
Thanks!
PS: I'm using node.js and express.