CrossFilter
Class: CrossFilter<Schema, TableName>
A type-safe filter builder supporting both simple conditions and complex nested groups.
Type Parameters
Schema
Schema extends object = any
The full database schema type
TableName
TableName extends keyof Schema = Extract<keyof Schema, string>
The specific table being filtered
Constructors
Constructor
new CrossFilter<Schema, TableName>(schema?): CrossFilter<Schema, TableName>
Parameters
schema?
Schema
Returns
CrossFilter<Schema, TableName>
Methods
add()
add<ColumnName, Op>(condition): this
Adds a single filter condition to the root group with an implicit AND conjunction. Performs type-safe validation if a schema is provided.
Type Parameters
ColumnName
ColumnName extends string
Op
Op extends keyof OperatorValueMap<any>
Parameters
condition
FilterConditionInput<OperatorValueMap<InferClickHouseType<Schema[TableName][ColumnName]>>[Op], Schema, Schema[TableName]>
Returns
this
addGroup()
addGroup(groupConditions, operator): this
Adds a nested group of filter conditions to the root group using the specified logical operator.
Parameters
groupConditions
(FilterGroup<Schema, Schema[TableName]> | FilterConditionInput<any, Schema, Schema[TableName]>)[]
Array of filter conditions or nested groups to be grouped together.
operator
Logical operator (‘AND’ or ‘OR’) to combine the conditions in the group.
"AND" | "OR"
Returns
this
addMultiple()
addMultiple(conditions): this
Adds multiple filter conditions to the root group.
Parameters
conditions
FilterConditionInput<any, Schema, Schema[TableName]>[]
Returns
this
getConditions()
getConditions(): FilterGroup<Schema, Schema[TableName]>
Returns the current filter tree representing all conditions and groups.
Returns
FilterGroup<Schema, Schema[TableName]>
topN()
topN<K>(valueColumn, n, orderBy): this
Creates a filter for top N records by a value column
Type Parameters
K
K extends string | number | symbol
Parameters
valueColumn
K
The column to filter and order by
n
number
Number of records to return
orderBy
Sort direction, defaults to ‘desc’
"desc" | "asc"
Returns
this