Skip to content

Corrected example in docs #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/usage/reading/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GET /users?filter=equals(displayName,null) HTTP/1.1
GET /users?filter=equals(displayName,lastName) HTTP/1.1
```

Comparison operators can be combined with the `count` function, which acts on HasMany relationships:
Comparison operators can be combined with the `count` function, which acts on to-many relationships:

```http
GET /blogs?filter=lessThan(count(owner.articles),'10') HTTP/1.1
Expand All @@ -60,14 +60,16 @@ GET /customers?filter=has(orders)&filter=equals(lastName,'Smith') HTTP/1.1
```

Aside from filtering on the resource being requested (which would be blogs in /blogs and articles in /blogs/1/articles),
filtering on included collections can be done using bracket notation:
filtering on to-many relationships can be done using bracket notation:

```http
GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[tags]=contains(label,'tech','design') HTTP/1.1
GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[tags]=any(label,'tech','design') HTTP/1.1
```

In the above request, the first filter is applied on the collection of articles, while the second one is applied on the nested collection of tags.

Note this does **not** hide articles without any matching tags! Use the `has` function with a filter condition (see below) to accomplish that.

Putting it all together, you can build quite complex filters, such as:

```http
Expand Down Expand Up @@ -112,7 +114,7 @@ Examples can be found in the table below.

Filters can be combined and will be applied using an OR operator. This used to be AND in versions prior to v4.0.

Attributes to filter on can optionally be prefixed with a HasOne relationship, for example:
Attributes to filter on can optionally be prefixed with to-one relationships, for example:

```http
GET /api/articles?include=author&filter[caption]=like:marketing&filter[author.lastName]=Smith HTTP/1.1
Expand Down