Class: QueryContext<T>
Type parameters
Name | Type |
---|---|
T | extends DocumentData = any |
Constructors
constructor
• new QueryContext<T
>(query
)
@internal.
Type parameters
Name | Type |
---|---|
T | extends DocumentData = any |
Parameters
Name | Type |
---|---|
query | Query <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
Name | Type |
---|---|
doc | DocumentData |
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
Name | Type | Description |
---|---|---|
...fieldNames | K [] | 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
Name | Type | Description |
---|---|---|
fieldName | K | The 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
Name | Type |
---|---|
F | F |
O | extends AllOperators |
Parameters
Name | Type | Description |
---|---|---|
fieldName | F | The name of the field for the condition. |
operator | O | The operator of the condition. |
value | null | 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
Name | Type | Description |
---|---|---|
condition | GeneralCondition <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
Name | Type | Description |
---|---|---|
conditions | GeneralConditions <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
Name | Type | Description |
---|---|---|
query | Query <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
Name | Type | Description |
---|---|---|
sorts | PartialBy <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
Name | Type | Description |
---|---|---|
sorts | PartialBy <FieldSort <T >, "asc" >[] | An array of field sorts. |
Returns
boolean
Whether the query's sorts exactly match the provided field sorts.