Skip to main content

Class: JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A query builder that can participate in a join. To learn more about join queries, see the documentation.

Type parameters

NameType
Aliasesextends Record<Alias, Alias[]>
ReturnTypeextends Record<Alias, DocumentData>
LatestAliasextends Alias
RootAliasextends Alias

Hierarchy

Implements

Methods

addCompositeCondition

addCompositeCondition(conditions): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Parameters

NameType
conditionsSimpleCondition<any, string, Operator>[]

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Implementation of

SnapshotEmitter.addCompositeCondition


arrayIncludesAll

arrayIncludesAll(fieldName, values): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Adds a condition to the query to check if the specified field includes all the given values.

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuesPrimitiveFieldType[]The values to check for inclusion in the field array.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.arrayIncludesAll


arrayIncludesSome

arrayIncludesSome(fieldName, values): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Adds a condition to the query to check if the specified field includes any of the given values.

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuesPrimitiveFieldType[]The values to check for inclusion in the field array.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.arrayIncludesSome


arrayNotIncludes

arrayNotIncludes(fieldName, values): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Adds a condition to the query to check if the specified field does not include any of the given values.

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuesPrimitiveFieldType[]The values to check for non-inclusion in the field array.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.arrayNotIncludes


clone

clone(): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Implementation of

SnapshotEmitter.clone


dereference

dereference(): DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>

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

DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>

Implementation of

HasDereference.dereference


eq

eq(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '==', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.eq


extractData

extractData(data): Required<ReturnType>[RootAlias]

Parameters

NameType
dataWithDocumentReferences<ReturnType>

Returns

Required<ReturnType>[RootAlias]

Implementation of

SnapshotEmitter.extractData


flipSortOrder

flipSortOrder(): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Implementation of

SnapshotEmitter.flipSortOrder


getLimit

getLimit(): number

Returns

number

Implementation of

SnapshotEmitter.getLimit


getSortOrders

getSortOrders(): FieldSort<any>[]

Returns

FieldSort<any>[]

Implementation of

SnapshotEmitter.getSortOrders


grouped

grouped(): GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>

Returns

GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>

Inherit Doc

Implementation of

HasGrouped.grouped


gt

gt(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '>', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.gt


gte

gte(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '>=', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.gte


hasIsInner

hasIsInner(): boolean

Returns

boolean


in

in(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, 'in', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldType[]An array of values to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.in


join

join<NewAlias, NewReturnType, LeftAlias, IsInner>(queryBuilder, alias, joinFields, options): Omit<JoinQueryBuilder<Omit<Aliases, LeftAlias> & Record<LeftAlias, [...Aliases[LeftAlias][], NewAlias]> & Record<NewAlias, []>, ReturnType & IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>, NewAlias, RootAlias>, "limit" | "getLimit">

Joins this query with another join query and return a new query builder that can be used to query the joined documents.

Type parameters

NameType
NewAliasextends string
NewReturnTypeextends DocumentData
LeftAliasextends string
IsInnerextends boolean = false

Parameters

NameTypeDescription
queryBuilderQueryBuilder<NewReturnType>The query builder to join with
aliasExclude<NewAlias, keyof ReturnType>TODO
joinFieldsObjectTODO
joinFields.leftkeyof Required<ReturnType>[LeftAlias] & string-
joinFields.rightkeyof NewReturnType & string-
optionsObjectTODO
options.isInner?IsInner-
options.leftAliasLeftAlias-

Returns

Omit<JoinQueryBuilder<Omit<Aliases, LeftAlias> & Record<LeftAlias, [...Aliases[LeftAlias][], NewAlias]> & Record<NewAlias, []>, ReturnType & IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>, NewAlias, RootAlias>, "limit" | "getLimit">

A new query builder that can be used to query the joined documents

join<NewAlias, NewReturnType, IsInner>(queryBuilder, alias, joinFields, options?): Omit<JoinQueryBuilder<Omit<Aliases, LatestAlias> & Record<LatestAlias, [...Aliases[LatestAlias][], NewAlias]> & Record<NewAlias, []>, ReturnType & IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>, NewAlias, RootAlias>, "limit" | "getLimit">

Type parameters

NameType
NewAliasextends string
NewReturnTypeextends DocumentData
IsInnerextends boolean = false

Parameters

NameType
queryBuilderQueryBuilder<NewReturnType>
aliasExclude<NewAlias, keyof ReturnType>
joinFieldsObject
joinFields.leftkeyof Required<ReturnType>[LatestAlias] & string
joinFields.rightkeyof NewReturnType & string
options?Object
options.isInner?IsInner

Returns

Omit<JoinQueryBuilder<Omit<Aliases, LatestAlias> & Record<LatestAlias, [...Aliases[LatestAlias][], NewAlias]> & Record<NewAlias, []>, ReturnType & IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>, NewAlias, RootAlias>, "limit" | "getLimit">


like

like(fieldName, pattern, caseSensitive?): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, 'like', pattern).

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
patternstringThe 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?booleanWhether to use case-sensitive comparison. Defaults to true.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.like


limit

limit(limit): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

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

NameTypeDescription
limitnumberThe maximum number of results to return

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder

Implementation of

SnapshotEmitter.limit

Overrides

BaseQueryBuilder.limit


lt

lt(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '<', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.lt


lte

lte(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '<=', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.lte


neq

neq(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, '!=', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldTypeThe value to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.neq


nin

nin(fieldName, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, 'not in', value)

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
valuePrimitiveFieldType[]An array of values to compare against.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.nin


notLike

notLike(fieldName, pattern, caseSensitive?): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

A shortcut for where(fieldName, 'not like', pattern).

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType & stringThe name of the field to query.
patternstringThe 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?booleanWhether to use case-sensitive comparison. Defaults to true.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder.

Inherited from

BaseQueryBuilder.notLike


paginate

paginate(options?): Pagination<WithDocumentReferences<ReturnType>>

Returns a pagination wrapper for this query.

Parameters

NameTypeDescription
options?Partial<PaginationOptions>The pagination options. Defaults to { subscribe: true, pageSize: 100 }.

Returns

Pagination<WithDocumentReferences<ReturnType>>

Implementation of

SnapshotEmitter.paginate


peek

peek(): WithDocumentReferences<ReturnType>[]

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

WithDocumentReferences<ReturnType>[]

An array of query results.

Implementation of

SnapshotEmitter.peek


serialize

serialize(): SerializedJoinQuery

Returns

SerializedJoinQuery

Implementation of

SnapshotEmitter.serialize


snapshot

snapshot(): Promise<WithDocumentReferences<ReturnType>[]>

Returns a promise that resolves to the query results.

Returns

Promise<WithDocumentReferences<ReturnType>[]>

A promise that resolves to the query results.

Implementation of

SnapshotEmitter.snapshot


snapshots

snapshots(subscribe?): Observable<WithDocumentReferences<ReturnType>[]>

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

NameTypeDefault valueDescription
subscribebooleantrueWhether to subscribe to changes to the query results. Defaults to true.

Returns

Observable<WithDocumentReferences<ReturnType>[]>

An observable for the query results.

Implementation of

SnapshotEmitter.snapshots


sortBy

sortBy(fieldName, asc?): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

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

NameTypeDefault valueDescription
fieldNamestring | keyof ReturnType[RootAlias] & stringundefinedThe name of the field to sort by
ascbooleantrueWhether to sort in ascending order. Defaults to true.

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder

Overrides

BaseQueryBuilder.sortBy


throwIfInvalidLikePattern

throwIfInvalidLikePattern(pattern): void

Parameters

NameType
patternstring

Returns

void

Inherited from

BaseQueryBuilder.throwIfInvalidLikePattern


where

where(fieldName, operator, value): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

Adds a condition to the query.

Parameters

NameTypeDescription
fieldNamestring | keyof ReturnType[LatestAlias] & stringThe name of the field to query
operatorOperator | "in" | "not in"The operator to use
valuePrimitiveFieldType | PrimitiveFieldType[]The value to compare against

Returns

JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>

The query builder

Overrides

BaseQueryBuilder.where