Skip to content

SudoSOS Back-end API / helpers / QueryFilter

Class: QueryFilter ​

Constructors ​

Constructor ​

ts
new QueryFilter(): QueryFilter;

Returns ​

QueryFilter

Methods ​

applyFilter() ​

ts
static applyFilter(
   query, 
   mapping, 
params): SelectQueryBuilder<any>;

Applies the specified query filtering onto the given query builder.

Parameters ​

ParameterTypeDescription
querySelectQueryBuilder<any>The query builder to which to add where clauses.
mappingFilterMappingThe mapping of property names on the parameters object to property names in the query.
paramsFilterParametersThe object containing the actual parameter values.

Returns ​

SelectQueryBuilder<any>

The resulting query bulider.


createFilterWhereClause() ​

ts
static createFilterWhereClause(mapping, params): FindOptionsWhere<any>;

Creates a FindManyOptions object containing the conditions needed to apply the given filter.

Parameters ​

ParameterTypeDescription
mappingFilterMappingThe mapping of property names on the parameters object to property names in the query.
paramsFilterParametersThe object containing the actual parameter values.

Returns ​

FindOptionsWhere<any>

The where clause which can be used in a FindManyOptions object.


createFilterWhereDate() ​

ts
static createFilterWhereDate(fromDate?, tillDate?): Date | FindOperator<Date>;

Given a time range, return a find options filter that filters based on this range

Parameters ​

ParameterTypeDescription
fromDate?Date-
tillDate?Date-

Returns ​

Date | FindOperator<Date>


createFilterWhereDateRange() ​

ts
static createFilterWhereDateRange<Entity>(
   rangeStartAttributeName, 
   rangeEndAttributeName, 
   rangeFromDate?, 
   rangeTillDate?): FindOptionsWhere<Entity>[];

Return a filter options that only returns the attributes whose timeframe partially overlaps with the given timeframe

Type Parameters ​

Type Parameter
Entity extends BaseEntity

Parameters ​

ParameterTypeDescription
rangeStartAttributeNamekeyof { [P in string | number | symbol as Entity[P] extends Date ? P : never]: any }Name of the entity's attribute that defines the start of the timeframe
rangeEndAttributeNamekeyof { [P in string | number | symbol as Entity[P] extends Date ? P : never]: any }Name of the entity's attribute that defines the end of the timeframe
rangeFromDate?DateOptional start of the selecting timeframe
rangeTillDate?DateOptional end of the selecting timeframe

Returns ​

FindOptionsWhere<Entity>[]


extractUndefinedNumberOrArray() ​

ts
static extractUndefinedNumberOrArray(query): number | number[];

Extract the given query field and parse it to either undefined, a number or an array of numbers

Parameters ​

ParameterTypeDescription
queryany-

Returns ​

number | number[]