Skip to content

Commit

Permalink
docs: improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezcasas committed Aug 6, 2024
1 parent a9c1bc6 commit cc4cafd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/criteria-from-next-request/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
```sh
npm i @codelytv/criteria-from-next-request
```

## 💻 Usage

The criteria converter expect an url [with the following format](../criteria-from-url).
29 changes: 29 additions & 0 deletions packages/criteria-from-url/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,32 @@
```sh
npm i @codelytv/criteria-from-url
```

## 💻 Usage

The criteria converter expect an url with the following format:
* `filters`: An array of filters. Composed by:
- `field`: The field to filter by.
- `operator`: The operator to apply. [You can see here](https://github.com/CodelyTV/php-criteria/tree/main/packages/criteria) the valid operators list.
- `value`: The value to filter by.
* `orderBy`: The field to order by.
* `order`: The order to apply. `asc` or `desc`.
* `pageSize`: The number of items per page.
* `pageNumber`: The page number.

### Url examples
Url with one filter and no order or pagination:
```
http://localhost:3000/api/users?filters[0][field]=name&filters[0][operator]=CONTAINS&filters[0][value]=Javi
```

Url with two filter, order and pagination:
```
http://localhost:3000/api/users
?filters[0][field]=name&filters[0][operator]=CONTAINS&filters[0][value]=Javi
&filters[1][field]=email&filters[1][operator]=CONTAINS&filters[1][value]=gmail
&orderBy=name
&order=asc
&pageSize=10
&pageNumber=2
```

0 comments on commit cc4cafd

Please sign in to comment.