You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.5 KiB

1 year ago
# Site-O-Mat Query
## Installation
Setup this registry in your project .npmrc file:
```
1 year ago
@site-o-mat:registry=https://gitea.node001.net/api/packages/site-o-mat/npm/
1 year ago
```
Install with npm or yarn
```
1 year ago
npm i --save-dev @site-o-mat/query
yarn add --dev @site-o-mat/query
1 year ago
```
1 year ago
## Filter
Basic Usage:
```
1 year ago
import { Filter } from '@site-o-mat/query'
1 year ago
const filter = new Filter(options)
const isValid = filter.validate(result)
```
1 year ago
Options:
1 year ago
| Name | Type | Description |
|-------------|-----------|-------------|
| _eq | {Mixed} | is equal |
| _neq | {Mixed} | is not equal |
| _in | {Mixed} | in array |
| _lt | {Mixed} | is lesser than |
| _lte | {Mixed} | is lesser or equal than |
| _gt | {Mixed} | is greater than |
| _gte | {Mixed} | is greater or equal than |
| _null | {Boolean} | is null |
| _nnull | {Boolean} | is not null |
1 year ago
## Reduce
1 year ago
Skip or Limit Elements from a an Array.
1 year ago
Basic Usage:
```
1 year ago
import { reduce } from '@site-o-mat/query'
1 year ago
results = reduce({
limit: 5
}, results)
```
1 year ago
Options:
| Name | Type | Description |
|-------------|-----------|-------------|
| limit | {Number} | limit elements |
| offset | {Number} | skip elements |
1 year ago
## OrderBy
1 year ago
Order elements in Array by name of property, default is 'asc', a '-' of the name is 'desc'.
1 year ago
Basic Usage:
```
1 year ago
import { orderBy } from '@site-o-mat/query'
1 year ago
results = orderBy([
-published_at
], results)
```