Expand description
Query filter system inspired by Laravel Filter Query String
Provides a flexible, type-safe filtering system for database queries. Supports complex query expressions through URL-friendly parameters.
§Example Query String
?username[contain]=john&age[gt]=18&status[eq]=active&orderby=name&limit=10§Supported Operators
| Operator | Description | SQL Equivalent |
|---|---|---|
eq | Equal | field = value |
notEq | Not equal | field != value |
gt | Greater than | field > value |
gte / gtEq | Greater or equal | field >= value |
lt | Less than | field < value |
lte / ltEq | Less or equal | field <= value |
like | Case-sensitive LIKE | field LIKE value |
ilike | Case-insensitive LIKE | field ILIKE value |
notlike | NOT LIKE | field NOT LIKE value |
contain | Contains | field LIKE %value% |
notcontain | Does not contain | field NOT LIKE %value% |
startwith | Starts with | field LIKE value% |
endwith | Ends with | field LIKE %value |
in | In array | field IN (...) |
notin | Not in array | field NOT IN (...) |
between | Between two values | field BETWEEN a AND b |
notbetween | Not between | field NOT BETWEEN a AND b |
isnull | Is null | field IS NULL |
isnotnull | Is not null | field IS NOT NULL |
or | OR condition | OR field = value |
Re-exports§
pub use cursor::CursorPayload;pub use cursor::CursorError;pub use cursor::encode_cursor;pub use cursor::decode_cursor;
Modules§
- cursor
- Keyset (cursor) paging for the generic list endpoint.
Structs§
- Filter
Condition - A single filter condition
- Query
Filter - Complete query filter specification
- Query
Param Error - One query parameter that could not be applied.
- Sort
Spec - Sort specification
Enums§
- Filter
Logical - Logical operator for combining conditions
- Filter
Operator - Filter operator types
- Filter
Value - Filter condition value
- Query
Param Reason - Why a query parameter was refused. The code (
as_str) is the stable, snake_casereasonclients branch on. - Sort
Direction - Sort direction
Traits§
- Filterable
Entity - Trait for entities to declare which fields are allowed in filter queries.
Functions§
- attribute_
operator_ error attribute_query_errorfor an undefined-operator refusal that more than one filter could have raised:column_types(column name to Postgresdata_type, read from the catalog) narrows the candidates to the filters on columns the operator cannot apply to — a pattern operator on anything but text. Left unchanged when that is still not exactly one.- attribute_
query_ error - Name the query parameter behind a failed list-shaped statement.
- is_
internal_ key - True for a key in the framework’s internal
__namespace (__base_condition,__base_condition[eq], …), which no client-supplied filter may use. - is_
valid_ field - Validate a field name against an allow-list
- parse_
filters - Parse filter from query parameters HashMap
- sanitize_
field_ name - Sanitize a field name for SQL identifier use
- undefined_
operator - Whether
erris the database’s refusal of an operator its operand types lack, and whether it was a pattern operator (~~).