Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including json-query-chain with all npm packages installed. Try it out:

var jsonQueryChain = require("json-query-chain")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

json-query-chain v1.1.3

Chain queries onto POJOs to return precise results.

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

Search

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free