pypaginate.domain.specs
User-facing specification objects for filtering, sorting, and search.
Specs are immutable Pydantic models that users construct to describe what they want. Engines consume specs to execute the operations.
Attributes
Type alias for filter input accepted by engines and pipelines. |
|
Supported filter operator names (type-checked at definition time). |
Classes
Composite filter for nested AND/OR expressions. |
|
Declarative filter specification. |
|
Declarative search specification. |
|
Declarative sort specification. |
Functions
|
Create an AND group of filter conditions. |
|
Create an OR group of filter conditions. |
Module Contents
- class pypaginate.domain.specs.FilterGroup(/, **data: Any)
Bases:
pydantic.BaseModelComposite filter for nested AND/OR expressions.
Use
And()andOr()builder functions instead of constructing directly.Example:
And( Or(FilterSpec(field="a", value=1), FilterSpec(field="b", value=2)), Or(FilterSpec(field="c", value=3), FilterSpec(field="d", value=4)), ) # = (a=1 OR b=2) AND (c=3 OR d=4)
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pypaginate.domain.specs.FilterSpec(/, **data: Any)
Bases:
pydantic.BaseModelDeclarative filter specification.
Example:
FilterSpec(field="age", operator="gte", value=18) FilterSpec(field="name", operator="contains", value="john")
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pypaginate.domain.specs.SearchSpec(/, **data: Any)
Bases:
pydantic.BaseModelDeclarative search specification.
Example:
SearchSpec(query="john doe", fields=("name", "email")) SearchSpec(query="jhn", fields=("name",), fuzzy=FuzzyMode.FUZZY) SearchSpec(query="alice", fields=("name", "bio"), weights={"name": 2.0})
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pypaginate.domain.specs.SortSpec(/, **data: Any)
Bases:
pydantic.BaseModelDeclarative sort specification.
Example:
SortSpec(field="name") SortSpec(field="created_at", direction=SortDirection.DESC)
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pypaginate.domain.specs.And(*conditions: FilterSpec | FilterGroup) FilterGroup
Create an AND group of filter conditions.
- pypaginate.domain.specs.Or(*conditions: FilterSpec | FilterGroup) FilterGroup
Create an OR group of filter conditions.
- pypaginate.domain.specs.FilterInput
Type alias for filter input accepted by engines and pipelines.
- pypaginate.domain.specs.FilterOperator
Supported filter operator names (type-checked at definition time).