Skip to main content

Static Methods

create()

Creates a new instance of RequestQueryBuilder.
CreateQueryParams
Optional parameters to initialize the query builder
Example:

setOptions()

Sets global configuration options for all RequestQueryBuilder instances.
RequestQueryBuilderOptions
required
Configuration options including delimiters and parameter name mappings
Example:

getOptions()

Returns the current global configuration options.
Example:

Instance Methods

query()

Generates the final query string from the built query object.
boolean
default:true
Whether to URL-encode the query string
Returns: The generated query string Example:
If search() has been called, the filter and or parameters will be removed from the query object before generating the string.

select()

Specifies which fields to include in the response.
string[]
required
Array of field names to select
Returns: The builder instance for chaining Example:

Sets a complex search condition with support for nested AND/OR logic.
SCondition
required
Search condition object with field operators and logical combinations
Returns: The builder instance for chaining Example:
When search() is used, it overrides any filter or or conditions. These will not be included in the final query string.

setFilter()

Adds filter conditions (all must match - AND logic).
QueryFilter | QueryFilterArr | Array
Single filter, filter array, or array of filters
Returns: The builder instance for chaining Types:
  • QueryFilter: { field: string, operator: ComparisonOperator, value?: any }
  • QueryFilterArr: [string, ComparisonOperator, any?]
Example:

setOr()

Adds OR filter conditions (at least one must match).
QueryFilter | QueryFilterArr | Array
Single filter, filter array, or array of filters
Returns: The builder instance for chaining Example:

setJoin()

Joins related entities and optionally selects specific fields from them.
QueryJoin | QueryJoinArr | Array
Join configuration(s)
Returns: The builder instance for chaining Types:
  • QueryJoin: { field: string, select?: string[] }
  • QueryJoinArr: [string, string[]?]
Example:

sortBy()

Sorts results by one or more fields.
QuerySort | QuerySortArr | Array
Sort configuration(s)
Returns: The builder instance for chaining Types:
  • QuerySort: { field: string, order: 'ASC' | 'DESC' }
  • QuerySortArr: [string, 'ASC' | 'DESC']
Example:

setLimit()

Limits the number of results returned.
number
required
Maximum number of records to return
Returns: The builder instance for chaining Example:

setOffset()

Sets the offset for pagination (number of records to skip).
number
required
Number of records to skip
Returns: The builder instance for chaining Example:

setPage()

Sets the page number for page-based pagination.
number
required
Page number (1-based)
Returns: The builder instance for chaining Example:
Use either setOffset() or setPage() for pagination, not both. Page-based pagination is often more intuitive for users.

resetCache()

Resets the cache by setting the cache parameter to 0.
Returns: The builder instance for chaining Example:

setIncludeDeleted()

Includes soft-deleted records in the results.
number
required
Value to set (typically 1 to include deleted records)
Returns: The builder instance for chaining Example:

cond()

Converts a filter object to a condition string. This is mainly used internally but can be useful for custom implementations.
QueryFilter | QueryFilterArr
required
Filter to convert
'filter' | 'or' | 'search'
default:"search"
Condition type for validation
Returns: Formatted condition string Example:

Method Chaining

All instance methods (except query() and cond()) return this, allowing for fluent method chaining: