0.0.4 • Published 8 months ago
Query parser
@comodinx/query-parser is a module for parser query parameters on ORM object (sequelize).
Index
Download & Install
NPM
$ npm install @comodinx/query-parser
Source code
$ git clone https://gitlab.com/comodinx/query-parser.git
$ cd query-parser
$ npm install
How is it used?
This section was designed to facilitate the interpretation of query parameters.
What parameters are accepted?
Pagination
| Name | Type | Default Value | Description |
|---|
| page | number | 1 | Indicates which page of the list should be returned. |
| pageSize | number | null | Indicates the number of records per page. |
Sorting
| Name | Type | Default Value | Description |
|---|
| order | string | null | Sorting to apply in the search results. |
| | | Example, |
| | | createdAt-DESC |
Grouping
| Name | Type | Default Value | Description |
|---|
| group | string | null | Grouping to apply in the search results. |
| | | Example, |
| | | platform |
Filtering
| Name | Type | Default Value | Description |
|---|
| filters | string | null | Filters to apply in the search. |
| | | All table fields are applicable for filtering. |
| | | Example, |
| | | statusId eq 1 |
💡 For more details on how filters work and their syntax, check this link.
Relationships
| Name | Type | Default Value | Description |
|---|
| include | string | null | Relationships to include in the search results. |
| | | Example, |
| | | status,r-products |
Fields
| Name | Type | Default Value | Description |
|---|
| fields | string | "*" | Fields to include in the search results. |
| | | Example, |
| | | id,statusId |
Extras
| Name | Type | Default Value | Description |
|---|
| extras | string | null | Additional fields to include in the search results. |
| | | Example, |
| | | category,brand |
Tests
For more concrete examples, I INVITE YOU TO CHECK THE TESTS :)
Run unit tests
npm test