You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/doctrine-filters.md
+158Lines changed: 158 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,6 +186,7 @@ To add some search filters, choose over this new list:
186
186
- [PartialSearchFilter](#partial-search-filter) (filter using a `LIKE %value%`)
187
187
- [FreeTextQueryFilter](#free-text-query-filter) (allows you to apply multiple filters to multiple properties of a resource at the same time, using a single parameter in the URL)
188
188
- [OrFilter](#or-filter) (apply a filter using `orWhere` instead of `andWhere` )
189
+
- [ComparisonFilter](#comparison-filter) (add `gt`, `gte`, `lt`, `lte`, `ne` operators to an equality or UUID filter)
189
190
190
191
### Legacy SearchFilter (API Platform < 4.2))
191
192
@@ -491,6 +492,163 @@ This request will return all chickens where:
491
492
- OR
492
493
- the `ean` is exactly "FR123456".
493
494
495
+
## Comparison Filter
496
+
497
+
> [!NOTE]
498
+
> `ComparisonFilter` is experimental and its API may change before a stable release.
499
+
500
+
The comparison filter is a decorator that wraps an equality filter (such as `ExactFilter`) and adds comparison
501
+
operators to it. It lets clients filter a collection using greater-than, greater-than-or-equal, less-than,
502
+
less-than-or-equal, and not-equal comparisons on any filterable property.
503
+
504
+
Syntax: `?parameter[<gt|gte|lt|lte|ne>]=value`
505
+
506
+
Available operators:
507
+
508
+
| Operator | SQL equivalent | Description |
509
+
|---|---|---|
510
+
| `gt` | `>` | Strictly greater than |
511
+
| `gte` | `>=` | Greater than or equal to |
512
+
| `lt` | `<` | Strictly less than |
513
+
| `lte` | `<=` | Less than or equal to |
514
+
| `ne` | `!=` | Not equal to |
515
+
516
+
`ComparisonFilter` is a decorator: it is applied by wrapping another filter. The canonical pairing is with `ExactFilter`
517
+
for standard properties, or with `UuidFilter` for UUID columns.
518
+
It works for Doctrine ORM (`ApiPlatform\Doctrine\Orm\Filter\ComparisonFilter`) and Doctrine MongoDB ODM
0 commit comments