Skip to main content

Class: BaseQueryBuilder<MyDocType>

Query builder base class.

Type parameters

NameType
MyDocTypeextends DocumentData

Hierarchy

Constructors

constructor

new BaseQueryBuilder<MyDocType>()

Type parameters

NameType
MyDocTypeextends DocumentData

Methods

arrayIncludesAll

arrayIncludesAll(fieldName, values): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


arrayIncludesSome

arrayIncludesSome(fieldName, values): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


arrayNotIncludes

arrayNotIncludes(fieldName, values): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


eq

eq(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


gt

gt(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


gte

gte(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


in

in(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


like

like(fieldName, pattern, caseSensitive?): BaseQueryBuilder<MyDocType>

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

Parameters

NameTypeDescription
fieldNamestring | keyof MyDocType & 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

BaseQueryBuilder<MyDocType>

The query builder.


limit

Abstract limit(limit): BaseQueryBuilder<MyDocType>

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 limit to set.

Returns

BaseQueryBuilder<MyDocType>

The query builder.


lt

lt(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


lte

lte(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


neq

neq(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


nin

nin(fieldName, value): BaseQueryBuilder<MyDocType>

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

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.


notLike

notLike(fieldName, pattern, caseSensitive?): BaseQueryBuilder<MyDocType>

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

Parameters

NameTypeDescription
fieldNamestring | keyof MyDocType & 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

BaseQueryBuilder<MyDocType>

The query builder.


sortBy

Abstract sortBy(fieldName, asc?): BaseQueryBuilder<MyDocType>

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

NameTypeDescription
fieldNamestring | keyof MyDocType & stringThe name of the field to sort by.
asc?booleanWhether to sort in ascending order. Defaults to true.

Returns

BaseQueryBuilder<MyDocType>

The query builder.


throwIfInvalidLikePattern

throwIfInvalidLikePattern(pattern): void

Parameters

NameType
patternstring

Returns

void


where

Abstract where(fieldName, operator, value): BaseQueryBuilder<MyDocType>

Adds a condition to the query.

Parameters

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

Returns

BaseQueryBuilder<MyDocType>

The query builder.