Skip to main content

Class: QueryContext<T>

Type parameters

NameType
Textends DocumentData = any

Constructors

constructor

new QueryContext<T>(query)

@internal.

Type parameters

NameType
Textends DocumentData = any

Parameters

NameType
queryQuery<T>

Properties

query

Readonly query: Query<T>

Accessors

collectionName

get collectionName(): string

The name of the collection being queried.

Returns

string


integrationId

get integrationId(): string

The ID of the integration being queried.

Returns

string


limit

get limit(): number

The query limit if one exists, -1 otherwise.

Returns

number

Methods

documentMatchesQuery

documentMatchesQuery(doc): boolean

Returns true if the given document can be a result of the query. The method does not account for limit and sort order.

Parameters

NameType
docDocumentData

Returns

boolean


getConditionsFor

getConditionsFor<K>(...fieldNames): ContextConditions<T, K>

Returns all conditions that apply to any of the specified field names. This method provides a convenient way to retrieve all conditions that involve a specific set of fields.

Type parameters

Name
K

Parameters

NameTypeDescription
...fieldNamesK[]The field names for which to retrieve conditions.

Returns

ContextConditions<T, K>

An array of conditions that involve any of the specified field names.


getConditionsForField

getConditionsForField<K>(fieldName): ContextConditions<T, UnionKeys<{ [k in string | number | symbol]-?: k extends string | number ? Record<`${k}`, T[k]> | (Required<T>[k] extends any[] ? never : Required<T>[k] extends object ? ({ [k in keyof Required<T>[k]]-?: k extends string | number ? Record<`${k}.${k}`, Required<T>[k][k]> | (Required<Required<T>[k]>[k] extends any[] ? never : Required<...>[k] extends object ? { [k in keyof Required<...>[k]]-?: k extends string | number ? Record<...> | (Required<...>[k] extends any[] ? never : Required<...)[keyof any[any]] : never) : never }[keyof T]>>

Returns all conditions that apply to the specified field name. This method provides a convenient way to retrieve all conditions that involve a specific field.

Type parameters

Name
K

Parameters

NameTypeDescription
fieldNameKThe field name for which to retrieve conditions.

Returns

ContextConditions<T, UnionKeys<{ [k in string | number | symbol]-?: k extends string | number ? Record<`${k}`, T[k]> | (Required<T>[k] extends any[] ? never : Required<T>[k] extends object ? ({ [k in keyof Required<T>[k]]-?: k extends string | number ? Record<`${k}.${k}`, Required<T>[k][k]> | (Required<Required<T>[k]>[k] extends any[] ? never : Required<...>[k] extends object ? { [k in keyof Required<...>[k]]-?: k extends string | number ? Record<...> | (Required<...>[k] extends any[] ? never : Required<...)[keyof any[any]] : never) : never }[keyof T]>>

An array of conditions that involve the specified field name.


isSubqueryOf

isSubqueryOf<F, O>(fieldName, operator, value): boolean

Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates to a subset of the results that would be obtained by applying the parent condition. The subquery may also include additional conditions, as these only narrow the result set.

Type parameters

NameType
FF
Oextends AllOperators

Parameters

NameTypeDescription
fieldNameFThe name of the field for the condition.
operatorOThe operator of the condition.
valuenull | GenericValue<T, F, O>The value of the condition.

Returns

boolean

Whether the query is a subquery of the parent condition.


isSubqueryOfCondition

isSubqueryOfCondition(condition): boolean

Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates to a subset of the results that would be obtained by applying the parent condition. The subquery may also include additional conditions, as these only narrow the result set.

Parameters

NameTypeDescription
conditionGeneralCondition<T, UnionKeys<{ [k in string | number | symbol]-?: k extends string | number ? Record<`${k}`, T[k]> | (Required<T>[k] extends any[] ? never : Required<T>[k] extends object ? ({ [k in keyof Required<T>[k]]-?: k extends string | number ? Record<`${k}.${k}`, Required<T>[k][k]> | (Required<Required<T>[k]>[k] extends any[] ? never : Required<...>[k] extends object ? { [k in keyof Required<...>[k]]-?: k extends string | number ? Record<...> | (Required<...>[k] extends any[] ? never : Required<...)[keyof any[any]] : never) : never }[keyof T]>>The condition to validate.

Returns

boolean

Whether the query is a subquery of the parent condition.


isSubqueryOfConditions

isSubqueryOfConditions(conditions): boolean

Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include additional conditions, as these only narrow the result set.

Parameters

NameTypeDescription
conditionsGeneralConditions<T, UnionKeys<{ [k in string | number | symbol]-?: k extends string | number ? Record<`${k}`, T[k]> | (Required<T>[k] extends any[] ? never : Required<T>[k] extends object ? ({ [k in keyof Required<T>[k]]-?: k extends string | number ? Record<`${k}.${k}`, Required<T>[k][k]> | (Required<Required<T>[k]>[k] extends any[] ? never : Required<...>[k] extends object ? { [k in keyof Required<...>[k]]-?: k extends string | number ? Record<...> | (Required<...>[k] extends any[] ? never : Required<...)[keyof any[any]] : never) : never }[keyof T]>>The conditions to validate.

Returns

boolean

Whether the query includes subquery of the parent conditions.


isSubqueryOfQuery

isSubqueryOfQuery(query): boolean

Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates to a subset of the results that obtained for the parent query, including sorts and limits.

Parameters

NameTypeDescription
queryQuery<T>The query to validate.

Returns

boolean

Whether the query is a subquery of the parent query.


sortedBy

sortedBy(sorts): boolean

Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the sorts parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include additional fields in its sort order, but only after the specified sorts.

Parameters

NameTypeDescription
sortsPartialBy<FieldSort<T>, "asc">[]An array of field sorts.

Returns

boolean

Whether the query's sorts matches the provided field sorts.


sortedByExact

sortedByExact(sorts): boolean

Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the sorts parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present in the query.

Parameters

NameTypeDescription
sortsPartialBy<FieldSort<T>, "asc">[]An array of field sorts.

Returns

boolean

Whether the query's sorts exactly match the provided field sorts.