152 lines
4.9 KiB
HTML
152 lines
4.9 KiB
HTML
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<title>Wroten - json-query-chain</title>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
|
||
</head>
|
||
|
||
<body class="bg-gray-100">
|
||
<header>
|
||
<nav>
|
||
<ul><li>
|
||
<a href="/work-history/antharia/">
|
||
Web Design & Dev Intern at Antharia
|
||
</a>
|
||
</li><li>
|
||
<a href="/work-history/cyto-communications/">
|
||
Interactive Technologies Lead & Web Admin at Cyto Communications
|
||
</a>
|
||
</li><li>
|
||
<a href="/work-history/eyemaginations/">
|
||
Senior Web Engineer at Eyemaginations
|
||
</a>
|
||
</li><li>
|
||
<a href="/volunteering/theseed/">
|
||
Austin Give Camp - The SEED
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/json-query-chain/" aria-current="page">
|
||
json-query-chain
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/blabber-comic/">
|
||
blabber-comic
|
||
</a>
|
||
</li><li>
|
||
<a href="/volunteering/code2college/">
|
||
Code 2 College
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/svgdir2sprite/">
|
||
svgdir2sprite
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/my_spells/">
|
||
my_spells
|
||
</a>
|
||
</li><li>
|
||
<a href="/volunteering/gabriellas-smile-foundation/">
|
||
Gabriella’s Smile Foundation
|
||
</a>
|
||
</li><li>
|
||
<a href="/work-history/q2/">
|
||
Developer III at Q2ebanking
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/team-cli/">
|
||
team-cli
|
||
</a>
|
||
</li><li>
|
||
<a href="/work-history/allovue/">
|
||
Software Engineer at Allovue
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/sortable-recipes/">
|
||
sortable-recipes
|
||
</a>
|
||
</li><li>
|
||
<a href="/work-history/skillsengine/">
|
||
Lead Full-Stack Software Engineer at SkillsEngine
|
||
</a>
|
||
</li><li>
|
||
<a href="/repos/ember-select-light/">
|
||
ember-select-light
|
||
</a>
|
||
</li></ul>
|
||
</nav>
|
||
</header>
|
||
|
||
|
||
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||
<div class="max-w-3x1 mx-auto mb-5">
|
||
<div class="-ml-2 mt-8 flex flex-wrap items-baseline">
|
||
<h1 class="ml-8 mt-2 text-lg font-medium text-gray-900">
|
||
json-query-chain
|
||
</h1>
|
||
<p class="ml-2 mt-1 text-sm text-gray-500 truncate">in </p>
|
||
</div>
|
||
</div>
|
||
<div class="bg-white overflow-hidden shadow sm:rounded-lg">
|
||
<div class="px-4 py-5 sm:p-6">
|
||
<blockquote>
|
||
<p>Chain queries onto POJOs to return precise results.</p>
|
||
</blockquote>
|
||
<!--more-->
|
||
<p><a href="https://gitlab.com/gaiety/json-query-chain">Fork on Gitlab</a></p>
|
||
<h1>json-query-chain</h1>
|
||
<p><a href="https://travis-ci.org/sharpshark28/json-query-chain"><img src="https://travis-ci.org/sharpshark28/json-query-chain.svg?branch=master" alt="Build Status"></a> <a href="https://badge.fury.io/js/json-query-chain"><img src="https://badge.fury.io/js/json-query-chain.svg" alt="npm version"></a> <img src="coverage.svg" alt="Code Coverage"> <a href="https://codeclimate.com/github/sharpshark28/json-query-chain/maintainability"><img src="https://api.codeclimate.com/v1/badges/4dc20d8b5e6a7334044d/maintainability" alt="Maintainability"></a></p>
|
||
<p>Chain queries onto POJOs to return precise results.</p>
|
||
<h2>Usage</h2>
|
||
<pre><code class="language-javascript">import Query from 'json-query-chain';
|
||
|
||
let myQ = new Query(someJsonData)
|
||
.search('isActiveUser', true)
|
||
.results;
|
||
</code></pre>
|
||
<h3>Chainable Methods</h3>
|
||
<h4>Search</h4>
|
||
<p>Currently supports booleans and strings. (See <a href="https://github.com/hergaiety/json-query-chain/issues/1">#1</a> for Integer Support)</p>
|
||
<h5>By Boolean</h5>
|
||
<pre><code class="language-javascript">.search('isActiveUser', true)
|
||
</code></pre>
|
||
<h5>By String</h5>
|
||
<pre><code class="language-javascript">.search('name', 'steele')
|
||
</code></pre>
|
||
<h4>Filter</h4>
|
||
<p>Simpler version of search using a custom function in the chain.</p>
|
||
<pre><code class="language-javascript">.filter(a => a.age >= 21)
|
||
</code></pre>
|
||
<h5>By Key</h5>
|
||
<pre><code class="language-javascript">.filterBy('age', x => x >= 21)
|
||
</code></pre>
|
||
<h4>Sort</h4>
|
||
<h5>By Boolean</h5>
|
||
<pre><code class="language-javascript">.sort('isActiveUser', true)
|
||
</code></pre>
|
||
<h5>By String</h5>
|
||
<pre><code class="language-javascript">.sort('name')
|
||
</code></pre>
|
||
<h5>By Number</h5>
|
||
<pre><code class="language-javascript">.sort('netWorth')
|
||
</code></pre>
|
||
<h4>Pagination</h4>
|
||
<p>Page 1 with 5 results per page.</p>
|
||
<pre><code class="language-javascript">.paginate(1, 5)
|
||
</code></pre>
|
||
<p>Page 2 wtih default of 10 results per page.</p>
|
||
<pre><code class="language-javascript">.paginate(2)
|
||
</code></pre>
|
||
<h2>Tests</h2>
|
||
<p><code>npm test</code> runs tests through Jest</p>
|
||
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
</body>
|
||
</html>
|
||
|
||
|
||
|