balderdashy/waterline — pull request #187 by m3talsmith (2013-12-01 22:51:45+00:00)
Title: Added pagination to deferred

This is syntactical sugar that makes use of ```Deferred.skip()``` and ```Deferred.limit()```, along with some pagination logic, to make it easier do pagination with waterline.

I added 11 test cases for you to look over. The use case is basically:

``` javascript
User.find().paginate({limit: 10});
// Returns the first 10 users

User.find().paginate({page: 1, limit: 10});
// Returns the first 10 users

User.find().paginate({page: 2, limit: 10});
// Returns the next 10 users

User.find().paginate();
// Returns all the users as if no pagination was done

User.find().paginate({page: 1});
// Returns all the users skipping none

User.find().paginate({page: 2});
// Returns all the users skipping the first one
```

I'm finding myself using pagination logic a lot with waterline (and sails). This work was done as an optional interface to dry up that work. I'm completely up to changing the semantics (for example using skip instead of page), just let you me know what you need.

Cheers!