Class: QueryBuilder<DocumentType>
A query builder that can be used to build a query that returns a list of documents.
Type parameters
Name | Type |
---|---|
DocumentType | extends DocumentData |
Hierarchy
BaseQueryBuilder
<DocumentType
>↳
QueryBuilder
Implements
SnapshotEmitter
<DocumentReference
<DocumentType
>>HasDereference
Accessors
hash
• get
hash(): string
A unique hash for the query. Identical queries should return the same hash value.
Returns
string
The query's hash string.
Methods
addCompositeCondition
▸ addCompositeCondition(conditions
): QueryBuilder
<DocumentType
>
Parameters
Name | Type |
---|---|
conditions | SimpleCondition <any , string , Operator >[] |
Returns
QueryBuilder
<DocumentType
>
Implementation of
SnapshotEmitter.addCompositeCondition
arrayIncludesAll
▸ arrayIncludesAll(fieldName
, values
): QueryBuilder
<DocumentType
>
Adds a condition to the query to check if the specified field includes all the given values.
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
values | PrimitiveFieldType [] | The values to check for inclusion in the field array. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
BaseQueryBuilder.arrayIncludesAll
arrayIncludesSome
▸ arrayIncludesSome(fieldName
, values
): QueryBuilder
<DocumentType
>
Adds a condition to the query to check if the specified field includes any of the given values.
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
values | PrimitiveFieldType [] | The values to check for inclusion in the field array. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
BaseQueryBuilder.arrayIncludesSome
arrayNotIncludes
▸ arrayNotIncludes(fieldName
, values
): QueryBuilder
<DocumentType
>
Adds a condition to the query to check if the specified field does not include any of the given values.
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
values | PrimitiveFieldType [] | The values to check for non-inclusion in the field array. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
BaseQueryBuilder.arrayNotIncludes
changes
▸ changes(): Observable
<Changes
<DocumentType
>>
Returns
Observable
<Changes
<DocumentType
>>
Inherit Doc
clone
▸ clone(): QueryBuilder
<DocumentType
>
Returns
QueryBuilder
<DocumentType
>
Implementation of
SnapshotEmitter.clone
dereference
▸ dereference(): SnapshotEmitter
<DocumentType
>
Dereferences the document references in the result of this query. For example, collection.query().snapshot() returns an array of DocumentReference objects, but collection.query().dereference().snapshot() returns an array of the actual document data.
Returns
SnapshotEmitter
<DocumentType
>
Implementation of
eq
▸ eq(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '==', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
flipSortOrder
▸ flipSortOrder(): QueryBuilder
<DocumentType
>
Returns
QueryBuilder
<DocumentType
>
Implementation of
SnapshotEmitter.flipSortOrder
getLimit
▸ getLimit(): number
Returns
number
Implementation of
SnapshotEmitter.getLimit
getSortOrder
▸ getSortOrder(): FieldSort
<DocumentType
>[]
Returns
FieldSort
<DocumentType
>[]
getSortOrders
▸ getSortOrders(): FieldSort
<any
>[]
Returns
FieldSort
<any
>[]
Implementation of
SnapshotEmitter.getSortOrders
gt
▸ gt(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '>', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
gte
▸ gte(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '>=', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
in
▸ in(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, 'in', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType [] | An array of values to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
like
▸ like(fieldName
, pattern
, caseSensitive?
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, 'like', pattern).
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
pattern | string | The pattern to compare against. '%' matches 0 or more characters. '' matches exactly one character. '\' can be used to escape '%', ''. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid. |
caseSensitive? | boolean | Whether to use case-sensitive comparison. Defaults to true. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
limit
▸ limit(limit
): QueryBuilder
<DocumentType
>
Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000 if none is provided.
Parameters
Name | Type | Description |
---|---|---|
limit | number | The limit to set. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Implementation of
SnapshotEmitter.limit
Overrides
limitBy
▸ limitBy(limit
, ...fields
): QueryBuilder
<DocumentType
>
Parameters
Name | Type |
---|---|
limit | number |
...fields | string [] |
Returns
QueryBuilder
<DocumentType
>
lt
▸ lt(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '<', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
lte
▸ lte(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '<=', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
neq
▸ neq(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, '!=', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
nin
▸ nin(fieldName
, value
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, 'not in', value)
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
value | PrimitiveFieldType [] | An array of values to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
notLike
▸ notLike(fieldName
, pattern
, caseSensitive?
): QueryBuilder
<DocumentType
>
A shortcut for where(fieldName, 'not like', pattern).
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
pattern | string | The pattern to compare against. '%' matches 0 or more characters. '' matches exactly one character. '\' can be used to escape '%', ''. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid. |
caseSensitive? | boolean | Whether to use case-sensitive comparison. Defaults to true. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Inherited from
paginate
▸ paginate(options?
): Pagination
<DocumentReference
<DocumentType
>>
Returns a pagination wrapper for this query.
Parameters
Name | Type | Description |
---|---|---|
options? | Partial <PaginationOptions > | The pagination options. Defaults to { subscribe: true, pageSize: 100 } . |
Returns
Pagination
<DocumentReference
<DocumentType
>>
Implementation of
peek
▸ peek(): DocumentReference
<DocumentType
>[]
Returns the results of the query based on the data that is currently available on the client. This method is useful for synchronously accessing data that has already been fetched by another query. The method will return an empty array if data has not yet been populated.
Returns
DocumentReference
<DocumentType
>[]
An array of query results.
Implementation of
serialize
▸ serialize(): SerializedSimpleQuery
Returns
Implementation of
setForceFetchFromServer
▸ setForceFetchFromServer(): QueryBuilder
<DocumentType
>
Forces the query to return data from the server even if there is a query that already returned the requested result.
Returns
QueryBuilder
<DocumentType
>
snapshot
▸ snapshot(): Promise
<DocumentReference
<DocumentType
>[]>
Returns a promise that resolves to the query results.
Returns
Promise
<DocumentReference
<DocumentType
>[]>
A promise that resolves to the query results.
Implementation of
snapshots
▸ snapshots(subscribe?
): Observable
<DocumentReference
<DocumentType
>[]>
Returns an observable that emits the query results and updates whenever the query results change unless
subscribe=false
is provided.
Important: Make sure to unsubscribe from the observable when you are done with it.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
subscribe | boolean | true | Whether to subscribe to changes to the query results. Defaults to true . |
Returns
Observable
<DocumentReference
<DocumentType
>[]>
An observable for the query results.
Implementation of
sortBy
▸ sortBy(fieldName
, asc?
): QueryBuilder
<DocumentType
>
Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them determines the order in which they are applied.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
fieldName | string | keyof DocumentType & string | undefined | The name of the field to sort by. |
asc | boolean | true | Whether to sort in ascending order. Defaults to true. |
Returns
QueryBuilder
<DocumentType
>
The query builder.
Overrides
throwIfInvalidLikePattern
▸ throwIfInvalidLikePattern(pattern
): void
Parameters
Name | Type |
---|---|
pattern | string |
Returns
void
Inherited from
BaseQueryBuilder.throwIfInvalidLikePattern
where
▸ where(fieldName
, operator
, value
): QueryBuilder
<DocumentType
>
Adds a condition to the query.
Parameters
Name | Type | Description |
---|---|---|
fieldName | string | keyof DocumentType & string | The name of the field to query. |
operator | Operator | "in" | "not in" | The operator to use. |
value | PrimitiveFieldType | PrimitiveFieldType [] | The value to compare against. |
Returns
QueryBuilder
<DocumentType
>
The query builder.