<commit_before>
# mongoose-paginate - [![Build Status](https://secure.travis-ci.org/edwardhotchkiss/mongoose-paginate.png)](http://travis-ci.org/edwardhotchkiss/mongoose-paginate)

> Mongoose ORM (NodeJS/MongoDB) Document Query Pagination

## Installation

```bash
$ npm install mongoose-paginate
```

## Usage 

```javascript

/*
 * basic example usage of `mongoose-pagination`
 * querying for `all` {} items in `MyModel`
 * paginating by second page, 10 items per page (10 results, page 2)
 */

var mongoose = require('mongoose-paginate');

MyModel.paginate({}, 2, 10, function(error, pageCount, paginatedResults, itemCount) {
  if (error) {
    console.error(error);
  } else {
  	console.log('Pages:', pageCount);
    console.log(paginatedResults);
  }
});

```

## Run Tests

``` bash
$ npm test
```

### Author: [<NAME>][0]

[0]: http://edwardhotchkiss.com/


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/edwardhotchkiss/mongoose-paginate/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

<commit_msg>[docs, sort, advanced] added docs for sort, select<commit_after>
# mongoose-paginate - [![Build Status](https://secure.travis-ci.org/edwardhotchkiss/mongoose-paginate.png)](http://travis-ci.org/edwardhotchkiss/mongoose-paginate)

> Mongoose ORM (NodeJS/MongoDB) Document Query Pagination

## Installation

```bash
$ npm install mongoose-paginate
```

## Usage 

#### Basic

```javascript

/*
 * basic example usage of `mongoose-pagination`
 * querying for `all` {} items in `MyModel`
 * paginating by second page, 10 items per page (10 results, page 2)
 */

var mongoose = require('mongoose-paginate');

MyModel.paginate({}, 2, 10, function(error, pageCount, paginatedResults, itemCount) {
  if (error) {
    console.error(error);
  } else {
  	console.log('Pages:', pageCount);
    console.log(paginatedResults);
  }
});

```

#### Advanced

```javascript

/*
 * basic example usage of `mongoose-pagination`
 * querying for `all` {} items in `MyModel`
 * paginating by second page, 10 items per page (10 results, page 2)
 */

var mongoose = require('mongoose-paginate');

MyModel.paginate({}, 2, 10, { columns: 'title', { populate: 'some_ref' }, sortBy : { title : -1 } }, function(error, pageCount, paginatedResults, itemCount) {
  if (error) {
    console.error(error);
  } else {
    console.log('Pages:', pageCount);
    console.log(paginatedResults);
  }
});

```

## Run Tests

``` bash
$ npm test
```

### Author: [<NAME>][0]

[0]: http://edwardhotchkiss.com/


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/edwardhotchkiss/mongoose-paginate/trend.png)](https://bitdeli.com/free "Bitdeli Badge")


{'fraction_non_alphanumeric': 0.16982562547384383, 'fraction_numerical': 0.014783927217589083, 'mean_word_length': 4.52092050209205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5336921', 'n_tokens_mistral': 981, 'n_tokens_neox': 948, 'n_words': 197}