Thomas Thomas - 2 years ago 116
Node.js Question

How to paginate with Mongoose in Node.js?

I am writing a webapp with Node.js and mongoose. How can I paginate the results I get from a

call? I would like a functionality comparable to
"LIMIT 50,100"
in SQL.

Answer Source

After taking a closer look at the Mongoose API with the information provided by Rodolphe, I figured out this solution:

MyModel.find(query, fields, { skip: 10, limit: 5 }, function(err, results) { ... });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download