minq-paged

return a paged query result set from a minq query

minq-paged

return a paged query result set from a minq query

var minq = require('minq')
var minqPaged = require('minq-paged')
 
// assume minq.connect() is called or another db connection is supplied 
 
minqPaged(minq.from('plays')
  .where({category: 'history'})
  .limit(10))
  .toArray()
  .then(function (results) {
 
  console.log(results.length)
  // => 10 
  console.log(results.totalLength)
  // => 54 
 
  })
 

minqPaged makes it convenient to run a paginated query and also return a count of the total resultSet. This involves running a second count query using the same where clause. This module adds totalLength, as well as other pagination properties, to the result set array.

using jsig

minqPaged: (query: [minq/Query](https://github.com/jden/minq#queryfromcollectionname-string--query)) => PagedQuery

type PagedQuery: {
  toArray: () => Promise<PagedResultSet>
}
 
type PagedResultSet: Array & {
  totalLength: Int,
  limit: Int?,
  skip: Int?,
  nextSkip: Int,
  sortOrder: Object?
}
 
$ npm install minq-paged

From package root:

$ npm install
$ npm test

MIT. (c) 2013 jden jason@denizac.org. See LICENSE.md