Skip to main content

Query Params Integration

Criteria can be constructed directly from URL query parameters, making it perfect for REST APIs.

Basic Usage

Query Parameter Format

Filters follow the pattern: field:operator=value, nested under the filters key:

Supported Parameters

Complete Example

Value Parsing

Values are automatically parsed to their correct types:

Nested Fields in Query Params

Quantifiers in Query Params

Use @quantifier suffix for array field quantifiers:

Field Adapters

Adapters map domain field names to database column names, allowing you to maintain clean API contracts while using different database schemas.

Why Use Adapters?

Creating an Adapter

Using an Adapter

Nested Field Adapters

Map nested paths to different structures:

Adapter with Prefix Matching

Adapters support prefix matching for nested paths:

Getting the Adapter

Serialization

toJSON()

Convert criteria to a plain object:
Result:

toQueryObject()

Convert criteria to a QueryParamsObject — useful when you need the structured object before converting to URL params:

toQueryParams()

Convert criteria directly to URLSearchParams for use in HTTP requests:
toQueryParams() and fromQueryParams() use the QueryParamsObject structure (with a filters key). When integrating with an HTTP server, parse the filters query param as JSON before passing it to fromQueryParams.

fromObject()

Reconstruct criteria from a plain object:

Use Cases for Serialization

API Transport

Send criteria from frontend to backend

Caching

Cache query configurations

Saved Filters

Store user’s saved filter presets

Logging

Log query configurations for debugging

Cloning

Create independent copies for query variations:

Error Handling

Invalid Operator

Invalid Quantifier

Express.js Integration Example

Fastify Integration Example

Frontend Integration Example

CriteriaAdapter Type Reference