Chain queries onto POJOs to return precise results.
Find a file
2020-09-21 23:27:13 +00:00
.eslintrc.js Eslint 2018-02-22 19:14:15 -06:00
.gitignore Coverage badge 2018-02-22 18:45:22 -06:00
.travis.yml Code climate fixes, travis config, badge 2017-08-20 20:21:44 -05:00
coverage.svg Coverage badge 2018-02-22 18:45:22 -06:00
index.js Eslint 2018-02-22 19:14:15 -06:00
index.test.js Eslint 2018-02-22 19:14:15 -06:00
LICENSE Add LICENSE 2019-08-07 03:33:03 +00:00
package.json Update package.json 2020-09-21 23:27:13 +00:00
README.md Code climate badge fix 2018-02-22 18:54:57 -06:00
testdata.json Test to prove sorting by integer works 2017-08-17 18:17:06 -05:00

json-query-chain

Build Status npm version Code Coverage Maintainability

Chain queries onto POJOs to return precise results.

Usage

import Query from 'json-query-chain';

let myQ = new Query(someJsonData)
.search('isActiveUser', true)
.results;

Chainable Methods

Currently supports booleans and strings. (See #1 for Integer Support)

By Boolean
.search('isActiveUser', true)
By String
.search('name', 'steele')

Filter

Simpler version of search using a custom function in the chain.

.filter(a => a.age >= 21)
By Key
.filterBy('age', x => x >= 21)

Sort

By Boolean
.sort('isActiveUser', true)
By String
.sort('name')
By Number
.sort('netWorth')

Pagination

Page 1 with 5 results per page.

.paginate(1, 5)

Page 2 wtih default of 10 results per page.

.paginate(2)

Tests

npm test runs tests through Jest