# js-query-client-utils

> A set of client utility classes that offer query parameter building with pagination, filtering and sorting

Latest version **0.3.0** (published 2019-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-query-client-utils
pnpm add js-query-client-utils
yarn add js-query-client-utils
bun add js-query-client-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2019-02-06 |
| First published | 2019-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel Edmonds |
| Maintainers | danielpedmonds |

## Links

- npm: https://www.npmjs.com/package/js-query-client-utils
- Repository: https://github.com/danielpedmonds/js-query-api-utils
- Homepage: https://github.com/danielpedmonds/js-query-api-utils#readme
- Issues: https://github.com/danielpedmonds/js-query-api-utils/issues
- npm.io page: https://npm.io/package/js-query-client-utils

## Recent versions

- 0.3.0 (latest) — 2019-02-06
- 0.2.0 — 2019-02-06
- 0.1.0 — 2019-01-29

## README

# js-query-api-utils

This library provides a utility builder class '/lib/ClientQuery.js' for building api query parameters containing pagination, filtering and sorting, to be used to call APIs that the ['java-query-api-utils'](https://github.com/danielpedmonds/java-query-api-utils) project. All of the key field names and operators can be found in '/lib/ApiQueryParamaters.js'.

## Pagination
Pagination can be implemented using the .addPaginationParameters(size, page) function passing parameters:
- **'size'** - defines the maximum number of records to return.
- **'page'** - defines which page of results to return as an offset based on page.
Both values should be a positive integer, greater than zero.
```
  e.g.  new Builder().addPaginationParameters(1, 25).build();

  		/find-users?page=1&size=25
```
## Sorting
Sorting is implemented using the .addSortingParameters(field, order) function taking parameters:
 - **'field'**  - the name of the field to be sorted.
 - **'order'** - the direction of sort, which can be one of two values:
 -- **'asc'** - defines ascending order.
 -- **'desc'** - defines descending order.
 ```
  e.g.  new Builder().addSortingParameters("firstName", spec.SORTING_ASCENDING_PARAMETER).build();

  		/find-users?sort=firstName:asc
```
 This get mapped to a ORDER BY clause constructed using JOOQs .orderBy method

## Filtering
Filtering can be implemented using the .addFilterParameters(filed, value, operator) function taking paramaters:
 - **'field'**  - the name of the field to be filtered
 - **'value'** - the value that you want to compare
 - **'operator'** - the operator to be used for field comparison:
 -- **'eq'** - Equal (used by default)
 -- **'neq'** - Not equal
 -- **'lk'** - Like
 -- **'gt'** - Greater than
 -- **'gte'** - Greater than or equal
 -- **'lt'** - Less than
 -- **'lte'** - Less than or equal
```
  e.g. new Builder().addFilterParameters("fistName", "Daniel", spec.FILTERING_EQUAL_OPERATOR).build();

  		/find-users?fullName=Daniel:eq
```

---
_Source: https://npm.io/package/js-query-client-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
